force default parameter IIFE on reference to eval
This commit is contained in:
@@ -12,8 +12,10 @@ var hasDefaults = function (node) {
|
||||
|
||||
var iifeVisitor = {
|
||||
ReferencedIdentifier(node, parent, scope, state) {
|
||||
if (!state.scope.hasOwnBinding(node.name)) return;
|
||||
if (state.scope.bindingIdentifierEquals(node.name, node)) return;
|
||||
if (node.name !== "eval") {
|
||||
if (!state.scope.hasOwnBinding(node.name)) return;
|
||||
if (state.scope.bindingIdentifierEquals(node.name, node)) return;
|
||||
}
|
||||
|
||||
state.iife = true;
|
||||
this.stop();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
let x = "outside";
|
||||
function outer(a = () => eval("x")) {
|
||||
let x = "inside";
|
||||
return a();
|
||||
}
|
||||
outer();
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var x = "outside";
|
||||
function outer() {
|
||||
var a = arguments[0] === undefined ? function () {
|
||||
return eval("x");
|
||||
} : arguments[0];
|
||||
return (function () {
|
||||
var x = "inside";
|
||||
return a();
|
||||
})();
|
||||
}
|
||||
outer();
|
||||
Reference in New Issue
Block a user