cmd/compile: fix ICE with new(<untyped expr>)

Fixes #75617

Change-Id: Iaee7d4556db54b9999f5ba8458e7c05c11ccfc36
Reviewed-on: https://go-review.googlesource.com/c/go/+/707075
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Cuong Manh Le 2025-09-26 18:07:18 +07:00 committed by Gopher Robot
parent 7d7cd6e07b
commit 0f31d742cd
2 changed files with 8 additions and 0 deletions

View file

@ -2434,6 +2434,7 @@ func (r *reader) expr() (res ir.Node) {
if r.Bool() {
// new(expr) -> tmp := expr; &tmp
x := r.expr()
x = typecheck.DefaultLit(x, nil) // See TODO in exprConvert case.
var init ir.Nodes
addr := ir.NewAddrExpr(pos, r.tempCopy(pos, x, &init))
addr.SetInit(init)

View file

@ -29,4 +29,11 @@ func main() {
panic("wrong value")
}
}
{
var i int
v := new(i > 0) // untyped expression, see issue #75617
if *v != false {
panic("wrong value")
}
}
}