diff options
| author | Keith Randall <khr@golang.org> | 2022-07-18 11:47:19 -0700 |
|---|---|---|
| committer | Keith Randall <khr@google.com> | 2022-08-08 16:58:57 +0000 |
| commit | 2493072db68a8f8b545bb2a6faebac0da0f01336 (patch) | |
| tree | aa3634bcab3894c6382b3c68c7340a43370e27ba /src/cmd/compile/internal/noder/transform.go | |
| parent | c3833a55433f4b2981253f64444fe5c3d1bc910a (diff) | |
| download | go-2493072db68a8f8b545bb2a6faebac0da0f01336.tar.xz | |
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 <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/transform.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/transform.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/noder/transform.go b/src/cmd/compile/internal/noder/transform.go index ddbccf4ff4..50254e694a 100644 --- a/src/cmd/compile/internal/noder/transform.go +++ b/src/cmd/compile/internal/noder/transform.go @@ -730,11 +730,11 @@ func transformAppend(n *ir.CallExpr) ir.Node { 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 } |
