aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/issue45547.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-04-14 14:54:14 -0700
committerDan Scales <danscales@google.com>2021-04-15 00:14:55 +0000
commitbf634c76b28a4a857c9d2a039c53982ffbdcceb7 (patch)
tree7a9d022e51719f6671861d98d3e58d40efc7fcdb /test/typeparam/issue45547.go
parent567a9322ad1980d22896efc3b642eedf997eb6d9 (diff)
downloadgo-bf634c76b28a4a857c9d2a039c53982ffbdcceb7.tar.gz
go-bf634c76b28a4a857c9d2a039c53982ffbdcceb7.zip
cmd/compile: look for function in instantiations in all global assignments
Add in some missing global assignment ops to the list of globals ops that should be traversed to look for generic function instantiations. The most common other one for global assigments (and the relevant one for this bug) is OAS2FUNC, but also look at global assigments with OAS2DOTTYPE, OAS2MAPR, OAS2RECV, and OASOP. Bonus small fix: get rid of -G=3 case in ir.IsAddressable. Now that we don't call the old typechecker from noder2, we don't need this -G-3 check anymore. Fixes #45547. Change-Id: I75fecec55ea0d6f62e1c2294d4d77447ed9be6ae Reviewed-on: https://go-review.googlesource.com/c/go/+/310210 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test/typeparam/issue45547.go')
-rw-r--r--test/typeparam/issue45547.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/typeparam/issue45547.go b/test/typeparam/issue45547.go
new file mode 100644
index 0000000000..0a08d66b70
--- /dev/null
+++ b/test/typeparam/issue45547.go
@@ -0,0 +1,20 @@
+// compile -G=3
+
+// Copyright 2021 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
+
+func f[T any]() (f, g T) { return f, g }
+
+// Tests for generic function instantiation on the right hande side of multi-value
+// assignments.
+
+func _() {
+ // Multi-value assignment within a function
+ var _, _ = f[int]()
+}
+
+// Multi-value assignment outside a function.
+var _, _ = f[int]()