possible bug?
complyue opened this issue · 2 comments
complyue commented
mhandugan commented
This is a “feature” of Go. There is no shadowing in this scenario.
https://golang.org/ref/spec#Short_variable_declarations
Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block (or the parameter lists if the block is the function body) with the same type, and at least one of the non-blank variables is new. As a consequence, redeclaration can only appear in a multi-variable short declaration. Redeclaration does not introduce a new variable; it just assigns a new value to the original.
complyue commented
I see, I don't know why I (wrongly) assumed function result vars live in a separate scope.
thanks @mhandugan