1
0
mirror of https://github.com/golang/go synced 2024-11-19 22:24:49 -07:00
go/test/fixedbugs/issue20250.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

25 lines
713 B
Go

// errorcheck -0 -live -d=compilelater
// 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 20250: liveness differed with concurrent compilation
// due to propagation of addrtaken to outer variables for
// closure variables.
package p
type T struct {
s string
}
func f(a T) { // ERROR "live at entry to f: a"
var e interface{}
func() { // ERROR "live at entry to f.func1: a &e"
e = a.s // ERROR "live at call to convT2Estring: a &e" "live at call to writebarrierptr: a"
}() // ERROR "live at call to f.func1: e$"
// Before the fix, both a and e were live at the previous line.
_ = e
}