add let-scoping-return template to let scoping transformer

This commit is contained in:
Sebastian McKenzie 2014-11-10 08:16:47 +11:00
parent b2ab0dbedc
commit 9318d63b5c
2 changed files with 4 additions and 4 deletions

View File

@ -0,0 +1 @@
if (typeof RETURN === "object") return RETURN.v;

View File

@ -287,10 +287,9 @@ var run = function (forParent, block, parent, file, scope) {
if (has.hasReturn) {
// typeof ret === "object"
retCheck = t.ifStatement(
t.binaryExpression("===", t.unaryExpression("typeof", ret, true), t.literal("object")),
t.returnStatement(t.memberExpression(ret, t.identifier("v")))
);
retCheck = util.template("let-scoping-return", {
RETURN: ret,
});
// there's no `break` or `continue` so we can just push in the `if`
if (!has.hasBreak && !has.hasContinue) {