@@ -985,7 +985,6 @@ Compressor.prototype.compress = function(node) {
|
||||
var scan = ld || left instanceof AST_Destructured;
|
||||
switch (node.operator) {
|
||||
case "=":
|
||||
if (ld) assign(tw, ld);
|
||||
if (left.equals(right) && !left.has_side_effects(compressor)) {
|
||||
right.walk(tw);
|
||||
walk_prop(left);
|
||||
@@ -1009,12 +1008,12 @@ Compressor.prototype.compress = function(node) {
|
||||
case "||=":
|
||||
case "??=":
|
||||
var lazy = true;
|
||||
if (ld) assign(tw, ld);
|
||||
default:
|
||||
if (!scan) {
|
||||
mark_assignment_to_arguments(left);
|
||||
return walk_lazy();
|
||||
}
|
||||
assign(tw, ld);
|
||||
ld.assignments++;
|
||||
var fixed = ld.fixed;
|
||||
if (is_modified(compressor, tw, node, node, 0)) {
|
||||
@@ -1083,6 +1082,7 @@ Compressor.prototype.compress = function(node) {
|
||||
return;
|
||||
}
|
||||
var d = sym.definition();
|
||||
assign(tw, d);
|
||||
d.assignments++;
|
||||
if (!fixed || sym.in_arg || !safe_to_assign(tw, d)) {
|
||||
walk();
|
||||
@@ -1613,6 +1613,7 @@ Compressor.prototype.compress = function(node) {
|
||||
return node.value || make_node(AST_Undefined, node);
|
||||
}, function(name, fixed) {
|
||||
var d = name.definition();
|
||||
assign(tw, d);
|
||||
if (!d.first_decl && d.references.length == 0) d.first_decl = name;
|
||||
if (fixed && safe_to_assign(tw, d, true)) {
|
||||
mark(tw, d);
|
||||
|
||||
@@ -827,3 +827,143 @@ keep_access_after_call: {
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5860_drop_1: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
var a = {};
|
||||
a.p;
|
||||
var a;
|
||||
a.q;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect: {
|
||||
var a = {};
|
||||
a.p;
|
||||
var a;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5860_drop_2: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
a = {};
|
||||
a.p;
|
||||
var a;
|
||||
a.q;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect: {
|
||||
a = {};
|
||||
a.p;
|
||||
var a;
|
||||
console.log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5860_keep_1: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
var a = {};
|
||||
a.p;
|
||||
a.q;
|
||||
var a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
var a = {};
|
||||
a.p;
|
||||
var a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5860_keep_2: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
a = {};
|
||||
a.p;
|
||||
a.q;
|
||||
var a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
a = {};
|
||||
a.p;
|
||||
var a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
issue_5860_keep_3: {
|
||||
options = {
|
||||
pure_getters: "strict",
|
||||
reduce_vars: true,
|
||||
side_effects: true,
|
||||
}
|
||||
input: {
|
||||
var a = {};
|
||||
a.p;
|
||||
a.q;
|
||||
a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
var a = {};
|
||||
a.p;
|
||||
a = null;
|
||||
try {
|
||||
a.r;
|
||||
console.log("FAIL");
|
||||
} catch (e) {
|
||||
console.log("PASS");
|
||||
}
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user