diff options
author | Russ Cox <rsc@golang.org> | 2010-07-26 14:21:39 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-07-26 14:21:39 -0700 |
commit | 7b240e81354003c3a8ba6235bd38adfd07b3cc73 (patch) | |
tree | 1b2fbcd7ccbb5990c05f8878952b94d45841bd2d | |
parent | ad4f95d365999c43945d427f278994b8c05bdb2f (diff) | |
download | go-7b240e81354003c3a8ba6235bd38adfd07b3cc73.tar.gz go-7b240e81354003c3a8ba6235bd38adfd07b3cc73.zip |
gc: import dot shadowing bug
R=ken2
CC=golang-dev
https://golang.org/cl/1873047
-rw-r--r-- | src/cmd/gc/typecheck.c | 5 | ||||
-rw-r--r-- | test/fixedbugs/bug295.go | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 85a63124ae..39e5774048 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -1781,6 +1781,11 @@ typecheckcomplit(Node **np) typecheck(&l->right, Erv); continue; } + // Sym might have resolved to name in other top-level + // package, because of import dot. Redirect to correct sym + // before we do the lookup. + if(s->pkg != localpkg) + s = lookup(s->name); l->left = newname(s); l->left->typecheck = 1; f = lookdot1(s, t, t->type, 0); diff --git a/test/fixedbugs/bug295.go b/test/fixedbugs/bug295.go new file mode 100644 index 0000000000..fec2351f31 --- /dev/null +++ b/test/fixedbugs/bug295.go @@ -0,0 +1,17 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2010 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. + +package main + +import . "testing" // defines top-level T + +type S struct { + T int +} + +func main() { + _ = &S{T: 1} // should work +} |