aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2021-04-23 12:53:51 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2021-04-23 17:36:11 +0000
commit8c666697646bc820beb3725b3ff4a4cd5514bbe7 (patch)
treed9e7b655ed82f0e6a8cf17750dd334f0b8a7e9a7 /test
parentd4bfe006155ea0d9c2970e22fca5a027125c8a98 (diff)
downloadgo-8c666697646bc820beb3725b3ff4a4cd5514bbe7.tar.gz
go-8c666697646bc820beb3725b3ff4a4cd5514bbe7.zip
cmd/compile: make sure ascompatee walk lhs init statements
CL 281152 improved ascompatee by removing the call to safeExpr on lhs. But we forgot that lhs int statements, if any, must be walked prior saving subexpressions, which cause the bug in #45706. Fixes #45706 Change-Id: I0064315056ef4ca92ebf3c332c2e3a9bb2b26f68 Reviewed-on: https://go-review.googlesource.com/c/go/+/312632 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue45706.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/fixedbugs/issue45706.go b/test/fixedbugs/issue45706.go
new file mode 100644
index 0000000000..facf488b3d
--- /dev/null
+++ b/test/fixedbugs/issue45706.go
@@ -0,0 +1,16 @@
+// 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 p
+
+var i int
+var arr []*int
+var f func() int
+
+func g() {
+ for i, *(arr[f()]) = range []int{} {
+ }
+}