From: Robert Griesemer Date: Mon, 20 Oct 2025 22:02:23 +0000 (-0700) Subject: go/types, types2: only report version errors if new(expr) is ok otherwise X-Git-Tag: go1.26rc1~540 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=06e57e60a7ff6cbc9c608278cbac4db514c7161a;p=gostls13.git 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 Reviewed-by: Mark Freeman Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer --- diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 84acb4ca48..d4463bc4b0 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -639,31 +639,31 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // new(T) or new(expr) // (no argument evaluated yet) arg := argList[0] - check.exprOrType(x, arg, true) - var T Type + check.exprOrType(x, arg, false) + check.exclude(x, 1<