зеркало из https://github.com/CryptoPro/go.git
cmd/compile: fix rewriting slice literal call argument
When seeing Key:Value expression in slice literal, the compiler only needs to emit tmp var for the Value, not the whole expression. Fixes #49240 Change-Id: I7bda3c796a93c0fa1974f7c5930f38025dfa665c Reviewed-on: https://go-review.googlesource.com/c/go/+/360055 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Родитель
c6a0b6f2de
Коммит
f2ff1c6074
|
@ -337,7 +337,11 @@ func (e *escape) rewriteArgument(argp *ir.Node, init *ir.Nodes, call ir.Node, fn
|
|||
if arg := *argp; arg.Op() == ir.OSLICELIT {
|
||||
list := arg.(*ir.CompLitExpr).List
|
||||
for i := range list {
|
||||
visit(arg.Pos(), &list[i])
|
||||
el := &list[i]
|
||||
if list[i].Op() == ir.OKEY {
|
||||
el = &list[i].(*ir.KeyExpr).Value
|
||||
}
|
||||
visit(arg.Pos(), el)
|
||||
}
|
||||
} else {
|
||||
visit(call.Pos(), argp)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// compile
|
||||
|
||||
// Copyright 2021 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.
|
||||
|
||||
package p
|
||||
|
||||
func f() {
|
||||
go copy([]int{1: 0}, []int{})
|
||||
}
|
Загрузка…
Ссылка в новой задаче