summaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ir/expr.go
diff options
context:
space:
mode:
authorJunwei Zuo <zuojunwei.2023@bytedance.com>2023-04-12 18:53:51 +0800
committerGopher Robot <gobot@golang.org>2023-04-12 19:28:47 +0000
commit89567a35c11c343cf765d6fb1270e1250e50d83f (patch)
tree1f754dabde409cb231e5fa725e39e8bdf045b6b7 /src/cmd/compile/internal/ir/expr.go
parent134af2e3db41ca4be5ce8b466cfa57774dba8449 (diff)
downloadgo-git-89567a35c11c343cf765d6fb1270e1250e50d83f.tar.gz
cmd/compile: fix ir.StaticValue for ORANGE
Range statement will mutate the key and value, so we should treat them as reassigned. Fixes #59572 Change-Id: I9c6b67d938760a0c6a1d9739f2737c67af4a3a10 Reviewed-on: https://go-review.googlesource.com/c/go/+/483855 Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ir/expr.go')
-rw-r--r--src/cmd/compile/internal/ir/expr.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go
index 39ebc37634..3cf52debf9 100644
--- a/src/cmd/compile/internal/ir/expr.go
+++ b/src/cmd/compile/internal/ir/expr.go
@@ -958,6 +958,11 @@ func reassigned(name *Name) bool {
if isName(OuterValue(n.X)) {
return true
}
+ case ORANGE:
+ n := n.(*RangeStmt)
+ if isName(n.Key) || isName(n.Value) {
+ return true
+ }
case OCLOSURE:
n := n.(*ClosureExpr)
if Any(n.Func, do) {