Clear bindings immediately inside the TCO loop.

We have to ensure that this happens before any potentially-hoisted
declarations from default parameters.

Closes #1080.
This commit is contained in:
Brian Donovan
2015-03-24 20:15:14 -07:00
parent 8575392606
commit ed6421876a
5 changed files with 33 additions and 4 deletions

View File

@@ -179,10 +179,12 @@ class TailCallTransformer {
var declarations = flatten(map(this.vars, function (decl) {
return decl.declarations;
}, this));
var statement = reduceRight(declarations, function (expr, decl) {
var assignment = reduceRight(declarations, function (expr, decl) {
return t.assignmentExpression("=", decl.id, expr);
}, t.identifier("undefined"));
body.unshift(t.expressionStatement(statement));
var statement = t.expressionStatement(assignment);
statement._blockHoist = Infinity;
body.unshift(statement);
}
var paramDecls = this.paramDecls;