Repository navigation
Conversation
Stores through a slice are not visible in the backing allocation's referrers, so nonempty slices can be mistaken for known empty argument lists Treat unrecovered elements as unknown to avoid SA5009 false positives while retaining diagnostics for actual empty argument lists
scnsh
marked this pull request as draft
October 21, 2026 09:34
Author
|
Closing this PR to respect the contribution policy in CONTRIBUTING.md, which asks that problems be reported as issues rather than pull requests. The bug report, minimal reproduction, and version comparison remain available in #1845. Apologies for overlooking the contribution policy before opening this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1845
Summary
irutil.Varargrecovers arguments from stores through the backing array. Stores through the slice itself are not among that allocation's referrers, so a nonempty slice can incorrectly be reported as a known empty argument list. SA5009 then reports missing arguments for validfmt.Sprintfcalls.The loop argument used to reach the check through Phi/Sigma nodes in 2026.1. The newer SSA representation exposes the slice directly, making this incorrect empty-list result observable.
Only accept recovered arguments when their count matches the backing array length. Otherwise, let SA5009 skip the call because its argument values are unknown.
Evidence
After: both calls are accepted, while an actually empty slice still produces the expected missing-argument diagnostic.
go test ./staticcheck/sa5009 ./go/ir/irutilon Go 1.26.0 and Go 1.27.2.go test ./...on Go 1.27.2.go vet ./...and the rebuiltstaticcheck ./...on Go 1.27.2.Merge Danger
Door: two-way
Blast Radius: SA5009
SA5009 is the only in-repository caller of
irutil.Vararg. Incomplete recovery now returns an unknown result instead of a misleading argument list. Existing known-argument diagnostics remain covered by the analyzer fixtures.