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
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:
Code-Review: +1 by Robert Griesemer, +1 by Brett Howell, +2 by Alan Donovan
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI