Skip to content

Commit 0f31d74

Browse files
cuonglmgopherbot
authored andcommitted
cmd/compile: fix ICE with new(<untyped expr>)
Fixes golang#75617 Change-Id: Iaee7d4556db54b9999f5ba8458e7c05c11ccfc36 Reviewed-on: https://go-review.googlesource.com/c/go/+/707075 Reviewed-by: Junyang Shao <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Cuong Manh Le <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 7d7cd6e commit 0f31d74

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/cmd/compile/internal/noder/reader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,6 +2434,7 @@ func (r *reader) expr() (res ir.Node) {
24342434
if r.Bool() {
24352435
// new(expr) -> tmp := expr; &tmp
24362436
x := r.expr()
2437+
x = typecheck.DefaultLit(x, nil) // See TODO in exprConvert case.
24372438
var init ir.Nodes
24382439
addr := ir.NewAddrExpr(pos, r.tempCopy(pos, x, &init))
24392440
addr.SetInit(init)

test/newexpr.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ func main() {
2929
panic("wrong value")
3030
}
3131
}
32+
{
33+
var i int
34+
v := new(i > 0) // untyped expression, see issue #75617
35+
if *v != false {
36+
panic("wrong value")
37+
}
38+
}
3239
}

0 commit comments

Comments
 (0)