[go] go/types, types2: only report version errors if new(expr) is ok otherwise

1 view
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Oct 21, 2025, 5:41:43 PM (2 days ago) Oct 21
to Robert Griesemer, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Mark Freeman, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
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-by: Mark Freeman <markf...@google.com>
Reviewed-by: Robert Griesemer <g...@google.com>
Auto-Submit: Robert Griesemer <g...@google.com>
Files:
  • M src/cmd/compile/internal/types2/builtins.go
  • M src/go/types/builtins.go
  • M src/internal/types/testdata/check/builtins0.go
  • M src/internal/types/testdata/check/go1_25.go
  • A src/internal/types/testdata/fixedbugs/issue75986.go
Change size: M
Delta: 5 files changed, 91 insertions(+), 48 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Mark Freeman, +1 by Robert Griesemer
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I39e5516d3f8d191cc390a4d8b9911c312bbb177c
Gerrit-Change-Number: 713241
Gerrit-PatchSet: 3
Gerrit-Owner: Robert Griesemer <g...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Robert Griesemer <g...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages