]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal: support new(expr)
authorAlan Donovan <adonovan@google.com>
Thu, 18 Sep 2025 18:04:43 +0000 (14:04 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 23 Sep 2025 20:12:12 +0000 (13:12 -0700)
commit7bc1935db55c9d182617aba074f048f9c7573680
tree042fbd7352c4a890a43f19d214b00d4bbc26b19f
parenteb78f13c9f195ba11fd9518257b6e45997b14de5
cmd/compile/internal: support new(expr)

This CL adds compiler support for new(expr),
a feature of go1.26 that allows the user to specify
the initial value of the variable instead of its
type.

Also, a basic test of dynamic behavior.

See CL 704737 for spec change and CL 704935 for
type-checker changes.

For #45624

Change-Id: I65d27de1ee3aabb819b57cce8ea77f3073447757
Reviewed-on: https://go-review.googlesource.com/c/go/+/705157
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/type.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/writer.go
test/newexpr.go [new file with mode: 0644]
test/used.go