Skip to content

Commit

Permalink
Fix gorountine arguments not copied.
Browse files Browse the repository at this point in the history
Fixes #1498
  • Loading branch information
tttoad committed Jan 16, 2023
1 parent eee72d1 commit 9b4ea62
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions interp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,14 +1292,24 @@ func call(n *node) {
// The receiver is already passed in the function wrapper, skip it.
values = values[1:]
}
in := make([]reflect.Value, len(values))
for i, v := range values {
in[i] = v(f)
}

if goroutine {
// Goroutine's arguments should be copied.
in := make([]reflect.Value, len(values))
for i, v := range values {
value := v(f)
in[i] = reflect.New(value.Type()).Elem()
in[i].Set(value)
}

go callf(in)
return tnext
}

in := make([]reflect.Value, len(values))
for i, v := range values {
in[i] = v(f)
}
out := callf(in)
for i, v := range rvalues {
if v != nil {
Expand Down

0 comments on commit 9b4ea62

Please sign in to comment.