1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:17:57 -07:00
go/test/fixedbugs/issue22076.go
Matthew Dempsky f22ef70254 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>
2017-10-05 18:07:37 +00:00

26 lines
427 B
Go

// compile
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 22076: Couldn't use ":=" to declare names that refer to
// dot-imported symbols.
package p
import . "bytes"
var _ Reader // use "bytes" import
func _() {
Buffer := 0
_ = Buffer
}
func _() {
for Buffer := range []int{} {
_ = Buffer
}
}