diff options
| author | Robert Griesemer <gri@google.com> | 2026-02-25 15:35:48 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-23 11:31:10 -0700 |
| commit | 12bf7d8cd2572d7f6aef4a18e490461f1aa2f53e (patch) | |
| tree | e89c89ea24e30f8fa17252c43ba79520cad33418 | |
| parent | 943235a5e5f333db25e1675f68ea61416909b6a4 (diff) | |
| download | go-12bf7d8cd2572d7f6aef4a18e490461f1aa2f53e.tar.xz | |
[release-branch.go1.26] builtin: incorporate all feedback into doc string for new
The previously submitted CL didn't include some of the feedback
that was provided on the CL. Specifically, it didn't mention the
behavior of `new` for untyped constant arguments.
For #77584.
Fixes #77586.
Change-Id: I1668a79a655246e5a55a4741a6c564b7dd6707c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/749061
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 5c7d8a3e4896df7d2d0f9d9ec72248eb39e71f96)
Reviewed-on: https://go-review.googlesource.com/c/go/+/758221
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
| -rw-r--r-- | src/builtin/builtin.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/builtin/builtin.go b/src/builtin/builtin.go index eea9004842..be53077d9c 100644 --- a/src/builtin/builtin.go +++ b/src/builtin/builtin.go @@ -224,15 +224,14 @@ func max[T cmp.Ordered](x T, y ...T) T // min will return NaN. func min[T cmp.Ordered](x T, y ...T) T -// The built-in function new creates a new, initialized variable and returns +// The built-in function new allocates a new, initialized variable and returns // a pointer to it. It accepts a single argument, which may be either a type // or an expression. -// // If the argument is a type T, then new(T) allocates a variable of type T // initialized to its zero value. -// -// If the argument is an expression x, then new(x) allocates a variable of -// the type of x initialized to the value of x. +// Otherwise, the argument is an expression x and new(x) allocates a variable +// of the type of x initialized to the value of x. If that value is an untyped +// constant, it is first implicitly converted to its default type. func new(TypeOrExpr) *Type // The complex built-in function constructs a complex value from two |
