x/tools/go/analysis/passes/shadow: shadowing not detected on deferred usage #36581
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?What did you do?
ran
on
What did you expect to see?
This is a simplified example but the intention of the defer is to print whatever the value of
err
is before returning. Since theerr
is redeclared in the new scope it shadows the initial declaration err. Thedefer
then prints "deferred err is one" instead of the intended "deferred error is two".What did you see instead?
No vet error
The text was updated successfully, but these errors were encountered: