]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: only report version errors if new(expr) is ok otherwise
authorRobert Griesemer <gri@google.com>
Mon, 20 Oct 2025 22:02:23 +0000 (15:02 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 21 Oct 2025 21:41:38 +0000 (14:41 -0700)
commit06e57e60a7ff6cbc9c608278cbac4db514c7161a
treeb8add1cba93a0dd9b05ceaad8975517fd0c880cd
parent6c3d0d259f2d83a338a3a7da268e2dd5834aa35f
go/types, types2: only report version errors if new(expr) is ok otherwise

If new(expr) is used before Go 1.26, don't report version errors if there
are other problems with the expression.

While at it, implement multiple missing type checks for new(expr) and
add corresponding test cases that were missed in CL 704935 (tests for
no value expressions, generic types, untyped nil).

Reorganize/rename builtins0.go tests for new to match existing test case
patterns again.

Fixes #75986.
For #45624.

Change-Id: I39e5516d3f8d191cc390a4d8b9911c312bbb177c
Reviewed-on: https://go-review.googlesource.com/c/go/+/713241
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/builtins.go
src/go/types/builtins.go
src/internal/types/testdata/check/builtins0.go
src/internal/types/testdata/check/go1_25.go
src/internal/types/testdata/fixedbugs/issue75986.go [new file with mode: 0644]