]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: first argument to append must never be be nil
authorRobert Griesemer <gri@google.com>
Fri, 7 Nov 2025 23:50:14 +0000 (15:50 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 10 Nov 2025 20:48:02 +0000 (12:48 -0800)
commitcdf64106f621b47987f332d5003afaefd9204b08
tree6032107b574d8d43c4833ba27efee1343f2b557d
parenta0eb4548cfcf803da087b7ca461a2d48b9f17a58
go/types, types2: first argument to append must never be be nil

The current implementation followed the spec faithfully for
the special case for append. Per the spec:

As a special case, append also accepts a first argument assignable to
type []byte with a second argument of string type followed by ... .

As it happens, nil is assignable to []byte, so append(nil, ""...)
didn't get an error message but a subsequent assertion failed.

This CL ensures that the first argument to append is never nil and
always a slice. We should make the spec more precise (separate CL).

Fixes #76220.

Change-Id: I581d11827a75afbb257077814beea813d4fe2441
Reviewed-on: https://go-review.googlesource.com/c/go/+/718860
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Brett Howell <devbrett90@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/compile/internal/types2/builtins.go
src/go/types/builtins.go
src/internal/types/testdata/fixedbugs/issue76220.go [new file with mode: 0644]