summaryrefslogtreecommitdiff
path: root/test/fixedbugs/issue43164.dir
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-13 10:35:20 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-15 07:53:10 +0000
commit4c2d66f642286647b640bced33581e8b1665bfe8 (patch)
treec7fa15c8c2bdfde48dd618f6545fcd8676aad146 /test/fixedbugs/issue43164.dir
parent305d93ef84aed971145b3aa1bce1f9f389bc90c0 (diff)
downloadgo-git-4c2d66f642286647b640bced33581e8b1665bfe8.tar.gz
[dev.regabi] cmd/compile: use ir.Ident for imported identifiers
This CL substantially reworks how imported declarations are handled, and fixes a number of issues with dot imports. In particular: 1. It eliminates the stub ir.Name declarations that are created upfront during import-declaration processing, allowing this to be deferred to when the declarations are actually needed. (Eventually, this can be deferred even further so we never have to create ir.Names w/ ONONAME, but this CL is already invasive/subtle enough.) 2. During noding, we now use ir.Idents to represent uses of imported declarations, including of dot-imported declarations. 3. Unused dot imports are now reported after type checking, so that we can correctly distinguish whether composite literal keys are a simple identifier (struct literals) or expressions (array/slice/map literals) and whether it might be a use of a dot-imported declaration. 4. It changes the "redeclared" error messages to report the previous position information in the same style as other compiler error messages that reference other source lines. Passes buildall w/ toolstash -cmp. Fixes #6428. Fixes #43164. Fixes #43167. Updates #42990. Change-Id: I40a0a780ec40daf5700fbc3cfeeb7300e1055981 Reviewed-on: https://go-review.googlesource.com/c/go/+/277713 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/fixedbugs/issue43164.dir')
-rw-r--r--test/fixedbugs/issue43164.dir/a.go13
-rw-r--r--test/fixedbugs/issue43164.dir/b.go11
2 files changed, 24 insertions, 0 deletions
diff --git a/test/fixedbugs/issue43164.dir/a.go b/test/fixedbugs/issue43164.dir/a.go
new file mode 100644
index 0000000000..fa10e85061
--- /dev/null
+++ b/test/fixedbugs/issue43164.dir/a.go
@@ -0,0 +1,13 @@
+// Copyright 2020 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 p
+
+import . "strings"
+
+var _ = Index // use strings
+
+type t struct{ Index int }
+
+var _ = t{Index: 0}
diff --git a/test/fixedbugs/issue43164.dir/b.go b/test/fixedbugs/issue43164.dir/b.go
new file mode 100644
index 0000000000..b025927a05
--- /dev/null
+++ b/test/fixedbugs/issue43164.dir/b.go
@@ -0,0 +1,11 @@
+// Copyright 2020 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 p
+
+import . "bytes"
+
+var _ = Index // use bytes
+
+var _ = t{Index: 0}