mirror of
https://github.com/golang/go.git
synced 2026-02-06 18:00:01 +00:00
cmd/compile: don't double-walk the map argument of clear
mkcallstmt1 already walks the map argument of clear. mapClear then walks it again, which can cause problems if it is some syntax that is non-idempotent under walk. That is the case for the new way map lookups are being lowered in CL 736020. Fixes #77435 Change-Id: Ib2f6d7f2270308c2462aa276ed4413aaf7799fe3 Reviewed-on: https://go-review.googlesource.com/c/go/+/742120 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
513bb875bc
commit
b8bccb9798
2 changed files with 16 additions and 1 deletions
|
|
@ -477,7 +477,7 @@ func mapClear(m, rtyp ir.Node) ir.Node {
|
|||
// instantiate mapclear(typ *type, hmap map[any]any)
|
||||
fn := typecheck.LookupRuntime("mapclear", t.Key(), t.Elem())
|
||||
n := mkcallstmt1(fn, rtyp, m)
|
||||
return walkStmt(typecheck.Stmt(n))
|
||||
return typecheck.Stmt(n)
|
||||
}
|
||||
|
||||
// Lower n into runtime·memclr if possible, for
|
||||
|
|
|
|||
15
test/fixedbugs/issue77435.go
Normal file
15
test/fixedbugs/issue77435.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2026 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.
|
||||
|
||||
// Issue 77435: compiler crash on clear of map resulting
|
||||
// from a map lookup (or some other syntax that is
|
||||
// non-idempotent during walk).
|
||||
|
||||
package p
|
||||
|
||||
func f(s map[int]map[int]int) {
|
||||
clear(s[0])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue