]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: allow := to shadow dot-imported names
authorMatthew Dempsky <mdempsky@google.com>
Thu, 28 Sep 2017 06:52:04 +0000 (23:52 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 5 Oct 2017 18:07:37 +0000 (18:07 +0000)
commitf22ef70254a6a79834ed3fa21c4d1ccadeb758bd
tree45ba4eeb81b08d1e40be390bbc87984b7d61e0c4
parent3b8a031569f5f209e97c6a815fcf24a2c4c05e65
cmd/compile: allow := to shadow dot-imported names

Historically, gc optimistically parsed the left-hand side of
assignments as expressions. Later, if it discovered a ":=" assignment,
it rewrote the parsed expressions as declarations.

This failed in the presence of dot imports though, because we lost
information about whether an imported object was named via a bare
identifier "Foo" or a normal qualified "pkg.Foo".

This CL fixes the issue by specially noding the left-hand side of ":="
assignments.

Fixes #22076.

Change-Id: I18190ecdb863112e7d009e1687e6112eec559921
Reviewed-on: https://go-review.googlesource.com/66810
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/noder.go
test/fixedbugs/bug388.go
test/fixedbugs/issue20250.go
test/fixedbugs/issue22076.go [new file with mode: 0644]