On Mon, Oct 1, 2018 at 7:56 AM, Pierre Durand <pierredur...@gmail.com> wrote:
>
> My code:
> package main
>
> func main() {
> a := 1
> _ = func() {
> a := 2
> _ = a
> }
> _ = func() (a int) {
> a = 2
> return a
> }
> _ = a
> }
>
> "go vet -shadow" reports a problem with the first function/closure, but
> nothing for the second one.
> Why ?
>
> If I understand correctly, it doesn't consider variable declaration in a
> named return value to be a shadowing issue.
> Is it expected ?

It does seem that vet's -shadow option ignores the case where the
parameter name (both ordinary parameter and result parameter) in a
function literal shadows a local variable in the function.  That seems
like a reasonable choice to me.  If you disagree, please open an issue
at https://golang.org/issue, and we can sort it out.  Thanks.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to