if (node instanceof AST_LoopControl) return true;
if (node instanceof AST_SymbolRef) {
if (node.is_declared(compressor)) {
- if (node.fixed_value() || can_drop_symbol(node)) return false;
+ if (node.fixed_value()) return false;
+ if (can_drop_symbol(node)) {
+ return !(parent instanceof AST_PropAccess && parent.expression === node)
+ && is_arguments(node.definition());
+ }
} else if (parent instanceof AST_Assign && parent.operator == "=" && parent.left === node) {
return false;
}
return compressor.option("ie8") && node.name && lvalues.has(node.name.name);
}
if (node instanceof AST_PropAccess) {
- return side_effects || !value_def && node.expression.may_throw_on_access(compressor);
+ var exp = node.expression;
+ return side_effects || !value_def && exp.may_throw_on_access(compressor)
+ || exp instanceof AST_SymbolRef && is_arguments(exp.definition());
}
if (node instanceof AST_Spread) return true;
if (node instanceof AST_SymbolRef) {
}
expect_stdout: "1"
}
+
+issue_4430_1: {
+ options = {
+ collapse_vars: true,
+ pure_getters: "strict",
+ }
+ input: {
+ function f(a) {
+ switch (a = 1, arguments[0]) {
+ case 1:
+ return "PASS";
+ case 2:
+ return "FAIL";
+ }
+ }
+ console.log(f(2));
+ }
+ expect: {
+ function f(a) {
+ switch (a = 1, arguments[0]) {
+ case 1:
+ return "PASS";
+ case 2:
+ return "FAIL";
+ }
+ }
+ console.log(f(2));
+ }
+ expect_stdout: "PASS"
+}
+
+issue_4430_2: {
+ options = {
+ collapse_vars: true,
+ pure_getters: "strict",
+ }
+ input: {
+ function f(a) {
+ switch (a = 0, arguments[0]) {
+ case 0:
+ return "PASS";
+ case 1:
+ return "FAIL";
+ }
+ }
+ console.log(f(1));
+ }
+ expect: {
+ function f(a) {
+ switch (arguments[a = 0]) {
+ case 0:
+ return "PASS";
+ case 1:
+ return "FAIL";
+ }
+ }
+ console.log(f(1));
+ }
+ expect_stdout: "PASS"
+}