Skip to content

Commit

Permalink
fix: do not overwrite input for assign operators
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored Mar 12, 2020
1 parent 6e33f89 commit 78bbcda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions _test/bin3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import "fmt"

func main() {
str := "part1"
str += fmt.Sprintf("%s", "part2")
fmt.Println(str)
}

// Output:
// part1part2
6 changes: 4 additions & 2 deletions interp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 78bbcda

Please sign in to comment.