Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial handling for iterators #288

Merged
merged 4 commits into from
Oct 10, 2024
Merged

Add initial handling for iterators #288

merged 4 commits into from
Oct 10, 2024

Conversation

yuxincs
Copy link
Contributor

@yuxincs yuxincs commented Oct 10, 2024

NilAway is panicking on code that ranges over iterators. This PR adds initial handling for such that we assume the results from the iterators are always nonnil, without panicking.

See #287

@yuxincs yuxincs changed the base branch from main to yuxincs/handle-type-alias October 10, 2024 19:33
Copy link

github-actions bot commented Oct 10, 2024

Golden Test

Warning

❌ NilAway errors reported on stdlib are different 📈.

3211 errors on base branch (main, f74befd)
3215 errors on test branch (1e3e402)

Diffs
+ /opt/hostedtoolcache/go/1.23.2/x64/src/go/ast/commentmap_test.go:123:14: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- ast/commentmap.go:138:10: literal `nil` returned from `NewCommentMap()` in position 0
+ 	- ast/commentmap_test.go:123:14: result 0 of `NewCommentMap()` called `Comments()` via the assignment(s):
+ 		- `NewCommentMap(...)` to `cmap` at ast/commentmap_test.go:110:2
+ 
+ (Same nil source could also cause potential nil panic(s) at 2 other place(s): "ast/commentmap_test.go:160:8", and "ast/example_test.go:224:15".)
+ /opt/hostedtoolcache/go/1.23.2/x64/src/go/token/position.go:119:9: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- ast/issues_test.go:33:12: unassigned variable `tf` used as receiver to call `Base()`
+ 	- token/position.go:119:9: read by method receiver `f` accessed field `base`
+ /opt/hostedtoolcache/go/1.23.2/x64/src/go/token/position.go:119:9: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- ast/issues_test.go:39:86: unassigned variable `tf` used as receiver to call `Base()`
+ 	- token/position.go:119:9: read by method receiver `f` accessed field `base`
+ /opt/hostedtoolcache/go/1.23.2/x64/src/go/token/position.go:124:9: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- ast/issues_test.go:33:24: unassigned variable `tf` used as receiver to call `Size()`
+ 	- token/position.go:124:9: read by method receiver `f` accessed field `size`
+ /opt/hostedtoolcache/go/1.23.2/x64/src/go/token/position.go:124:9: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- ast/issues_test.go:39:97: unassigned variable `tf` used as receiver to call `Size()`
+ 	- token/position.go:124:9: read by method receiver `f` accessed field `size`
+ /opt/hostedtoolcache/go/1.23.2/x64/src/maps/example_test.go:18:2: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- maps/maps.go:53:10: literal `nil` returned from `Clone()` in position 0
+ 	- maps/example_test.go:18:2: result 0 of `Clone()` written to at an index via the assignment(s):
+ 		- `maps.Clone(m1)` to `m2` at maps/example_test.go:17:2
+ /opt/hostedtoolcache/go/1.23.2/x64/src/maps/maps_test.go:93:2: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- maps/maps.go:53:10: literal `nil` returned from `Clone()` in position 0
+ 	- maps/maps_test.go:93:2: result 0 of `Clone()` written to at an index via the assignment(s):
+ 		- `Clone(m1)` to `mc` at maps/maps_test.go:89:2
+ /opt/hostedtoolcache/go/1.23.2/x64/src/slices/slices.go:322:16: Potential nil panic detected. Observed nil flow from source to dereference point: 
+ 	- slices/slices.go:322:16: read directly from variadic parameter `v` sliced into
+ 
+ (Same nil source could also cause potential nil panic(s) at 3 other place(s): "slices/slices.go:323:20", "slices/slices.go:328:20", and "slices/slices.go:329:16".)
- /opt/hostedtoolcache/go/1.23.2/x64/src/internal/goarch/zgoarch_amd64.go:1:1: INTERNAL ERROR(s):
- nilaway_assertion_analyzer: nilaway_function_analyzer: analyzing function AppendSeq at /opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter.go:49.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter.go:50:6) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[E]
- /opt/hostedtoolcache/go/1.23.2/x64/src/internal/goarch/zgoarch_amd64.go:1:1: INTERNAL ERROR(s):
- nilaway_assertion_analyzer: nilaway_function_analyzer: analyzing function ExampleChunk at /opt/hostedtoolcache/go/1.23.2/x64/src/slices/example_test.go:388.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/slices/example_test.go:405:6) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[slices_test.People]
- analyzing function TestValues at /opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter_test.go:58.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter_test.go:66:7) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[int]
- analyzing function TestChunkRange at /opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter_test.go:275.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/slices/iter_test.go:278:6) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[[]int]
- /opt/hostedtoolcache/go/1.23.2/x64/src/internal/goarch/zgoarch_amd64.go:1:1: INTERNAL ERROR(s):
- nilaway_assertion_analyzer: nilaway_function_analyzer: analyzing function ExamplePreorder at /opt/hostedtoolcache/go/1.23.2/x64/src/go/ast/example_test.go:143.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/go/ast/example_test.go:159:6) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[go/ast.Node]
- analyzing function TestPreorderBreak at /opt/hostedtoolcache/go/1.23.2/x64/src/go/ast/walk_test.go:14.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/go/ast/walk_test.go:28:6) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[go/ast.Node]
- /opt/hostedtoolcache/go/1.23.2/x64/src/internal/goarch/zgoarch_amd64.go:1:1: INTERNAL ERROR(s):
- nilaway_assertion_analyzer: nilaway_function_analyzer: analyzing function TestKeys at /opt/hostedtoolcache/go/1.23.2/x64/src/maps/iter_test.go:32.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/maps/iter_test.go:42:7) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[int]
- analyzing function TestValues at /opt/hostedtoolcache/go/1.23.2/x64/src/maps/iter_test.go:52.1: backpropagation across node (/opt/hostedtoolcache/go/1.23.2/x64/src/maps/iter_test.go:62:7) of type *ast.AssignStmt failed for reason: unrecognized type of rhs in range statement: iter.Seq[int]

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.70%. Comparing base (f74befd) to head (46f8fa9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #288      +/-   ##
==========================================
- Coverage   87.91%   87.70%   -0.21%     
==========================================
  Files          66       66              
  Lines        7935     7949      +14     
==========================================
- Hits         6976     6972       -4     
- Misses        785      796      +11     
- Partials      174      181       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sonalmahajan15 sonalmahajan15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Base automatically changed from yuxincs/handle-type-alias to main October 10, 2024 20:14
@yuxincs yuxincs force-pushed the yuxincs/handle-iter branch from 696b309 to 46f8fa9 Compare October 10, 2024 20:15
@yuxincs yuxincs merged commit ba14292 into main Oct 10, 2024
9 checks passed
@yuxincs yuxincs deleted the yuxincs/handle-iter branch October 10, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants