mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: do not write implicit conversion for append in Unified IR
Same as CL 418475, but for Unified IR. Updates #53888 Fixes #54337 Change-Id: I31d5a7af04d8e3902ed25db85009d46ea4c38dbe Reviewed-on: https://go-review.googlesource.com/c/go/+/422040 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
a292b3905c
commit
2699065483
2 changed files with 8 additions and 2 deletions
|
|
@ -1989,6 +1989,13 @@ func (r *reader) expr() (res ir.Node) {
|
|||
case ir.OAPPEND:
|
||||
n := n.(*ir.CallExpr)
|
||||
n.RType = r.rtype(pos)
|
||||
// For append(a, b...), we don't need the implicit conversion. The typechecker already
|
||||
// ensured that a and b are both slices with the same base type, or []byte and string.
|
||||
if n.IsDDD {
|
||||
if conv, ok := n.Args[1].(*ir.ConvExpr); ok && conv.Op() == ir.OCONVNOP && conv.Implicit() {
|
||||
n.Args[1] = conv.X
|
||||
}
|
||||
}
|
||||
case ir.OCOPY:
|
||||
n := n.(*ir.BinaryExpr)
|
||||
n.RType = r.rtype(pos)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue