diff --git a/_test/bin3.go b/_test/bin3.go new file mode 100644 index 000000000..afb277ad3 --- /dev/null +++ b/_test/bin3.go @@ -0,0 +1,12 @@ +package main + +import "fmt" + +func main() { + str := "part1" + str += fmt.Sprintf("%s", "part2") + fmt.Println(str) +} + +// Output: +// part1part2 diff --git a/interp/run.go b/interp/run.go index 2f396040b..5db1887d0 100644 --- a/interp/run.go +++ b/interp/run.go @@ -901,8 +901,10 @@ func callBin(n *node) { return fnext } default: - switch n.anc.kind { - case defineStmt, assignStmt, defineXStmt, assignXStmt: + switch n.anc.action { + case aAssign, aAssignX: + // The function call is part of an assign expression, we write results direcly + // to assigned location, to avoid an additional assign operation. rvalues := make([]func(*frame) reflect.Value, funcType.NumOut()) for i := range rvalues { c := n.anc.child[i]