Skip to content

Decrement $stackDepthOffset in deferred wrapper func #1222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ func (fc *funcContext) translateCall(e *ast.CallExpr, sig *types.Signature, fun
// where we need to compute function and its arguments at the the keyword site,
// but the call itself will happen elsewhere (hence "delegated").
//
// Built-in functions and cetrain `js.Object` methods don't translate into JS
// Built-in functions and certain `js.Object` methods don't translate into JS
// function calls, and need to be wrapped before they can be delegated, which
// this function handles and returns JS expressions that are safe to delegate
// and behave like a regular JS function and a list of its argument values.
Expand Down Expand Up @@ -885,7 +885,7 @@ func (fc *funcContext) delegatedCall(expr *ast.CallExpr) (callable *expression,
Args: callArgs,
Ellipsis: expr.Ellipsis,
}
callable = fc.formatExpr("function(%s) { %e; }", strings.Join(vars, ", "), wrapper)
callable = fc.formatExpr("function(%s) { $stackDepthOffset--; %e; }", strings.Join(vars, ", "), wrapper)
arglist = fc.formatExpr("[%s]", strings.Join(args, ", "))
return callable, arglist
}
Expand Down