assert(t.IsSlice())
if n.IsDDD {
- if t.Elem().IsKind(types.TUINT8) && args[1].Type().IsString() {
- return n
- }
-
- args[1] = assignconvfn(args[1], t.Underlying())
+ // assignconvfn is of args[1] not required here, as the
+ // types of args[0] and args[1] don't need to match
+ // (They will both have an underlying type which are
+ // slices of indentical base types, or be []byte and string.)
+ // See issue 53888.
return n
}
--- /dev/null
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !race
+
+package test
+
+import (
+ "testing"
+)
+
+func TestAppendOfMake(t *testing.T) {
+ for n := 32; n < 33; n++ { // avoid stack allocation of make()
+ b := make([]byte, n)
+ f := func() {
+ b = append(b[:0], make([]byte, n)...)
+ }
+ if n := testing.AllocsPerRun(10, f); n > 0 {
+ t.Errorf("got %f allocs, want 0", n)
+ }
+ type S []byte
+
+ s := make(S, n)
+ g := func() {
+ s = append(s[:0], make(S, n)...)
+ }
+ if n := testing.AllocsPerRun(10, g); n > 0 {
+ t.Errorf("got %f allocs, want 0", n)
+ }
+ h := func() {
+ s = append(s[:0], make([]byte, n)...)
+ }
+ if n := testing.AllocsPerRun(10, h); n > 0 {
+ t.Errorf("got %f allocs, want 0", n)
+ }
+ i := func() {
+ b = append(b[:0], make(S, n)...)
+ }
+ if n := testing.AllocsPerRun(10, i); n > 0 {
+ t.Errorf("got %f allocs, want 0", n)
+ }
+ }
+}
return n
}
- args[1] = AssignConv(args[1], t.Underlying(), "append")
+ // AssignConv is of args[1] not required here, as the
+ // types of args[0] and args[1] don't need to match
+ // (They will both have an underlying type which are
+ // slices of indentical base types, or be []byte and string.)
+ // See issue 53888.
return n
}
}
if cap < old.cap {
- panic(errorString("growslice: cap out of range"))
+ panic(errorString("growslice: len out of range"))
}
if et.size == 0 {
// print(len(s), "\n")
// }
if overflow || capmem > maxAlloc {
- panic(errorString("growslice: cap out of range"))
+ panic(errorString("growslice: len out of range"))
}
var p unsafe.Pointer
func main() {
s := make([]T, maxInt)
- shouldPanic("cap out of range", func() { s = append(s, T{}) })
+ shouldPanic("len out of range", func() { s = append(s, T{}) })
var oneElem = make([]T, 1)
- shouldPanic("cap out of range", func() { s = append(s, oneElem...) })
+ shouldPanic("len out of range", func() { s = append(s, oneElem...) })
}
func shouldPanic(str string, f func()) {