36
lib/scope.js
36
lib/scope.js
@@ -234,19 +234,24 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
if (node.label) node.label.thedef.references.push(node);
|
||||
return true;
|
||||
}
|
||||
// ensure mangling works if `catch` reuses a scope variable
|
||||
if (node instanceof AST_SymbolCatch) {
|
||||
var def = node.definition().redefined();
|
||||
if (def) for (var s = node.scope; s; s = s.parent_scope) {
|
||||
push_uniq(s.enclosed, def);
|
||||
if (s === def.scope) break;
|
||||
if (node instanceof AST_SymbolDeclaration) {
|
||||
if (node instanceof AST_SymbolCatch) {
|
||||
// ensure mangling works if `catch` reuses a scope variable
|
||||
var def = node.definition().redefined();
|
||||
if (def) for (var s = node.scope; s; s = s.parent_scope) {
|
||||
push_uniq(s.enclosed, def);
|
||||
if (s === def.scope) break;
|
||||
}
|
||||
} else if (node instanceof AST_SymbolConst) {
|
||||
// ensure compression works if `const` reuses a scope variable
|
||||
var redef = node.definition().redefined();
|
||||
if (redef) redef.const_redefs = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// ensure compression works if `const` reuses a scope variable
|
||||
if (node instanceof AST_SymbolConst) {
|
||||
var redef = node.definition().redefined();
|
||||
if (redef) redef.const_redefs = true;
|
||||
if (node.name != "arguments") return true;
|
||||
var parent = node instanceof AST_SymbolVar && tw.parent();
|
||||
if (parent instanceof AST_VarDef && !parent.value) return true;
|
||||
var sym = node.scope.resolve().find_variable("arguments");
|
||||
if (sym && is_arguments(sym)) sym.scope.uses_arguments = 3;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
@@ -295,13 +300,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
||||
node.reference(options);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_VarDef) {
|
||||
if (node.value && node.name.name == "arguments") {
|
||||
var sym = node.name.scope.resolve().find_variable("arguments");
|
||||
if (sym && is_arguments(sym)) sym.scope.uses_arguments = 3;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
self.walk(tw);
|
||||
|
||||
|
||||
@@ -2189,7 +2189,7 @@ issue_4446: {
|
||||
|
||||
issue_4456: {
|
||||
options = {
|
||||
pure_getters: true,
|
||||
pure_getters: "strict",
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
@@ -2398,3 +2398,61 @@ issue_4512: {
|
||||
expect_stdout: "undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_4519_1: {
|
||||
options = {
|
||||
arguments: true,
|
||||
keep_fargs: false,
|
||||
}
|
||||
input: {
|
||||
try {
|
||||
(function() {
|
||||
var [ arguments ] = [];
|
||||
arguments[0];
|
||||
})();
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
try {
|
||||
(function() {
|
||||
var [ arguments ] = [];
|
||||
arguments[0];
|
||||
})();
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_4519_2: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
try {
|
||||
(function() {
|
||||
var [ arguments ] = [];
|
||||
arguments[0];
|
||||
})();
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
try {
|
||||
(function() {
|
||||
var [ arguments ] = [];
|
||||
arguments[0];
|
||||
})();
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user