Open jbert opened 3 years ago
I have a basic patch which considers range statements and successfully generates the warning above:
https://github.com/jbert/tools/tree/jb/shadow-check-range-vars
Is this appropriate to raise as a PR?
Supporting range statements in shadow.Analyzer sounds reasonable to me. It is not super far from the example given in the doc comment for the checker: https://github.com/golang/tools/blob/fe37c9e135b934191089b245ac29325091462508/go/analysis/passes/shadow/shadow.go#L33-L43
It is not obvious to me that it is going to break something that is currently idiomatic. For the criteria https://golang.org/src/cmd/vet/README , this is roughly in line with the existing shadow Analyzer. My guess is that this will be less frequent than the existing shadow
cases, but is frequent enough to warrant the incremental cost of examining more statements for folks already running shadow.
You can send the PR to me to review.
Sorry, unsure/don't have privs to assign to you.
PR link is here: https://github.com/golang/tools/pull/287
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Installed and ran the shadow analyzer on a file witht the contents below:
No warning was generated
What did you expect to see?
A message similar to:
What did you see instead?
No output from the shadow tool.