add let-scoping-return template to let scoping transformer
This commit is contained in:
parent
b2ab0dbedc
commit
9318d63b5c
1
lib/6to5/templates/let-scoping-return.js
Normal file
1
lib/6to5/templates/let-scoping-return.js
Normal file
@ -0,0 +1 @@
|
||||
if (typeof RETURN === "object") return RETURN.v;
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user