From f81b87cb14a4fd7fd1ac0e732d7cdb2a728caaa7 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Fri, 28 Jul 2023 16:35:34 +0200 Subject: [PATCH 1/2] Decrement in deferred wrapper func to fix #1127 --- compiler/expressions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/expressions.go b/compiler/expressions.go index db08cc31f..cf9ff597e 100644 --- a/compiler/expressions.go +++ b/compiler/expressions.go @@ -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 } From b3125d54b46173b7acc7ac2d0ee3c5585a3abef2 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Fri, 28 Jul 2023 16:35:48 +0200 Subject: [PATCH 2/2] Drive-by spelling correction --- compiler/expressions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/expressions.go b/compiler/expressions.go index cf9ff597e..8e79c877c 100644 --- a/compiler/expressions.go +++ b/compiler/expressions.go @@ -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.