@@ -985,7 +985,6 @@ Compressor.prototype.compress = function(node) {
|
|||||||
var scan = ld || left instanceof AST_Destructured;
|
var scan = ld || left instanceof AST_Destructured;
|
||||||
switch (node.operator) {
|
switch (node.operator) {
|
||||||
case "=":
|
case "=":
|
||||||
if (ld) assign(tw, ld);
|
|
||||||
if (left.equals(right) && !left.has_side_effects(compressor)) {
|
if (left.equals(right) && !left.has_side_effects(compressor)) {
|
||||||
right.walk(tw);
|
right.walk(tw);
|
||||||
walk_prop(left);
|
walk_prop(left);
|
||||||
@@ -1009,12 +1008,12 @@ Compressor.prototype.compress = function(node) {
|
|||||||
case "||=":
|
case "||=":
|
||||||
case "??=":
|
case "??=":
|
||||||
var lazy = true;
|
var lazy = true;
|
||||||
if (ld) assign(tw, ld);
|
|
||||||
default:
|
default:
|
||||||
if (!scan) {
|
if (!scan) {
|
||||||
mark_assignment_to_arguments(left);
|
mark_assignment_to_arguments(left);
|
||||||
return walk_lazy();
|
return walk_lazy();
|
||||||
}
|
}
|
||||||
|
assign(tw, ld);
|
||||||
ld.assignments++;
|
ld.assignments++;
|
||||||
var fixed = ld.fixed;
|
var fixed = ld.fixed;
|
||||||
if (is_modified(compressor, tw, node, node, 0)) {
|
if (is_modified(compressor, tw, node, node, 0)) {
|
||||||
@@ -1083,6 +1082,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var d = sym.definition();
|
var d = sym.definition();
|
||||||
|
assign(tw, d);
|
||||||
d.assignments++;
|
d.assignments++;
|
||||||
if (!fixed || sym.in_arg || !safe_to_assign(tw, d)) {
|
if (!fixed || sym.in_arg || !safe_to_assign(tw, d)) {
|
||||||
walk();
|
walk();
|
||||||
@@ -1613,6 +1613,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return node.value || make_node(AST_Undefined, node);
|
return node.value || make_node(AST_Undefined, node);
|
||||||
}, function(name, fixed) {
|
}, function(name, fixed) {
|
||||||
var d = name.definition();
|
var d = name.definition();
|
||||||
|
assign(tw, d);
|
||||||
if (!d.first_decl && d.references.length == 0) d.first_decl = name;
|
if (!d.first_decl && d.references.length == 0) d.first_decl = name;
|
||||||
if (fixed && safe_to_assign(tw, d, true)) {
|
if (fixed && safe_to_assign(tw, d, true)) {
|
||||||
mark(tw, d);
|
mark(tw, d);
|
||||||
|
|||||||
@@ -827,3 +827,143 @@ keep_access_after_call: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
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