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);
|
if (node.label) node.label.thedef.references.push(node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ensure mangling works if `catch` reuses a scope variable
|
if (node instanceof AST_SymbolDeclaration) {
|
||||||
if (node instanceof AST_SymbolCatch) {
|
if (node instanceof AST_SymbolCatch) {
|
||||||
var def = node.definition().redefined();
|
// ensure mangling works if `catch` reuses a scope variable
|
||||||
if (def) for (var s = node.scope; s; s = s.parent_scope) {
|
var def = node.definition().redefined();
|
||||||
push_uniq(s.enclosed, def);
|
if (def) for (var s = node.scope; s; s = s.parent_scope) {
|
||||||
if (s === def.scope) break;
|
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;
|
if (node.name != "arguments") return true;
|
||||||
}
|
var parent = node instanceof AST_SymbolVar && tw.parent();
|
||||||
// ensure compression works if `const` reuses a scope variable
|
if (parent instanceof AST_VarDef && !parent.value) return true;
|
||||||
if (node instanceof AST_SymbolConst) {
|
var sym = node.scope.resolve().find_variable("arguments");
|
||||||
var redef = node.definition().redefined();
|
if (sym && is_arguments(sym)) sym.scope.uses_arguments = 3;
|
||||||
if (redef) redef.const_redefs = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_SymbolRef) {
|
if (node instanceof AST_SymbolRef) {
|
||||||
@@ -295,13 +300,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
node.reference(options);
|
node.reference(options);
|
||||||
return true;
|
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);
|
self.walk(tw);
|
||||||
|
|
||||||
|
|||||||
@@ -2189,7 +2189,7 @@ issue_4446: {
|
|||||||
|
|
||||||
issue_4456: {
|
issue_4456: {
|
||||||
options = {
|
options = {
|
||||||
pure_getters: true,
|
pure_getters: "strict",
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -2398,3 +2398,61 @@ issue_4512: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=6"
|
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