mirror of
https://github.com/golang/go
synced 2024-11-11 19:21:37 -07:00
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>
This commit is contained in:
parent
d4bfe00615
commit
8c66669764
@ -341,6 +341,9 @@ func ascompatee(op ir.Op, nl, nr []ir.Node) []ir.Node {
|
||||
break
|
||||
}
|
||||
|
||||
walkStmtList(l.Init())
|
||||
early.Append(ir.TakeInit(l)...)
|
||||
|
||||
var name *ir.Name
|
||||
switch l.Op() {
|
||||
default:
|
||||
|
16
test/fixedbugs/issue45706.go
Normal file
16
test/fixedbugs/issue45706.go
Normal file
@ -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{} {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user