aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-04-24 02:12:55 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-04-26 21:27:41 +0000
commit9f601690da59e601ff68f9868d5eb863bd770eae (patch)
tree2f67e35635247aae34a3bc90d8771f7efcdd688e /test
parenta53dc4c1ce0e21da328bd5984900448bab354ba1 (diff)
downloadgo-9f601690da59e601ff68f9868d5eb863bd770eae.tar.gz
go-9f601690da59e601ff68f9868d5eb863bd770eae.zip
cmd/compile: workaround inlining of closures with type switches
Within clovar, n.Defn can also be *ir.TypeSwitchGuard. The proper fix here would be to populate m.Defn and have it filled in too, but we already leave it nil in inlvar. So for consistency, this CL does the same in clovar too. Eventually inl.go should be rewritten to fully respect IR invariants. Fixes #45743. Change-Id: I8b38e5d8b2329ad242de97670f2141f713954d28 Reviewed-on: https://go-review.googlesource.com/c/go/+/313289 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Dan Scales <danscales@google.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue45743.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/fixedbugs/issue45743.go b/test/fixedbugs/issue45743.go
new file mode 100644
index 0000000000..0b30e0f2a4
--- /dev/null
+++ b/test/fixedbugs/issue45743.go
@@ -0,0 +1,20 @@
+// compile
+
+// 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 main
+
+func fn() func(interface{}) {
+ return func(o interface{}) {
+ switch v := o.(type) {
+ case *int:
+ *v = 1
+ }
+ }
+}
+
+func main() {
+ fn()
+}