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

Refine tracking of slicing index #268

Open
sonalmahajan15 opened this issue Aug 12, 2024 · 0 comments · May be fixed by #293
Open

Refine tracking of slicing index #268

sonalmahajan15 opened this issue Aug 12, 2024 · 0 comments · May be fixed by #293
Labels
false positive Requires more analysis and support good first issue Good for newcomers

Comments

@sonalmahajan15
Copy link
Contributor

sonalmahajan15 commented Aug 12, 2024

For the below case, NilAway correctly tracks the implication of slicing an empty slice and does not report an error.

var x []int
_ = x[:0]

However, when the slicing index is a non-literal, like below, NilAway currently reports a false positive. Refine tracking of non-literal indices to understand such code patterns and avoid false positives. Update func (r *RootAssertionNode) isZeroSlicing(expr *ast.SliceExpr) bool { ... } method to add the support.

var x []int
_ = x[:min(len(x), 100)] // FP: unassigned variable `x` sliced into
@sonalmahajan15 sonalmahajan15 added good first issue Good for newcomers false positive Requires more analysis and support labels Aug 12, 2024
@fatelei fatelei linked a pull request Nov 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive Requires more analysis and support good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant