From 2493072db68a8f8b545bb2a6faebac0da0f01336 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 18 Jul 2022 11:47:19 -0700 Subject: cmd/compile: avoid assignment conversion in append(a, b...) There's no need for a and b to match types. The typechecker already ensured that a and b are both slices with the same base type, or a and b are (possibly named) []byte and string. The optimization to treat append(b, make([], ...)) as a zeroing slice extension doesn't fire when there's a OCONVNOP wrapping the make. Fixes #53888 Change-Id: Ied871ed0bbb8e4a4b35d280c71acbab8103691bc Reviewed-on: https://go-review.googlesource.com/c/go/+/418475 TryBot-Result: Gopher Robot Reviewed-by: Matthew Dempsky Reviewed-by: Cuong Manh Le Reviewed-by: Keith Randall Run-TryBot: Keith Randall --- src/runtime/slice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/slice.go b/src/runtime/slice.go index 9ca0adefd8..75f202fca0 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -194,7 +194,7 @@ func growslice(et *_type, old slice, cap int) slice { } if cap < old.cap { - panic(errorString("growslice: cap out of range")) + panic(errorString("growslice: len out of range")) } if et.size == 0 { @@ -284,7 +284,7 @@ func growslice(et *_type, old slice, cap int) slice { // 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 -- cgit v1.3