fix: do not pass twice the receiver in deferred method calls

This commit is contained in:
Marc Vertes
2020-03-23 13:40:03 +01:00
committed by GitHub
parent 4a22635585
commit 0a99eb48c3
2 changed files with 63 additions and 0 deletions

View File

@@ -669,6 +669,10 @@ func call(n *node) {
if n.anc.kind == deferStmt {
// Store function call in frame for deferred execution.
value = genFunctionWrapper(n.child[0])
if method {
// The receiver is already passed in the function wrapper, skip it.
values = values[1:]
}
n.exec = func(f *frame) bltn {
val := make([]reflect.Value, len(values)+1)
val[0] = value(f)