[go] go/types, types2: first argument to append must never be be nil

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Nov 10, 2025, 3:48:08 PM (2 days ago) Nov 10
to Robert Griesemer, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, Brett Howell, Mark Freeman, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
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
Auto-Submit: Robert Griesemer <g...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Reviewed-by: Robert Griesemer <g...@google.com>
Reviewed-by: Brett Howell <devbr...@gmail.com>
Files:
  • M src/cmd/compile/internal/types2/builtins.go
  • M src/go/types/builtins.go
  • A src/internal/types/testdata/fixedbugs/issue76220.go
Change size: M
Delta: 3 files changed, 39 insertions(+), 14 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Robert Griesemer, +1 by Brett Howell, +2 by Alan Donovan
  • 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: I581d11827a75afbb257077814beea813d4fe2441
Gerrit-Change-Number: 718860
Gerrit-PatchSet: 3
Gerrit-Owner: Robert Griesemer <g...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Brett Howell <devbr...@gmail.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