@@ -5674,12 +5674,11 @@ merge(Compressor.prototype, {
|
|||||||
var write_only = def.value.write_only;
|
var write_only = def.value.write_only;
|
||||||
var value = def.value.drop_side_effect_free(compressor);
|
var value = def.value.drop_side_effect_free(compressor);
|
||||||
if (def.value !== value) {
|
if (def.value !== value) {
|
||||||
def.value = value && make_sequence(def.value, [
|
def.value = null;
|
||||||
value,
|
if (value) {
|
||||||
make_node(AST_Number, def.value, {
|
AST_Node.warn("Side effects in last use of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
value: 0
|
side_effects.push(value);
|
||||||
}),
|
}
|
||||||
]);
|
|
||||||
} else if (def.value.write_only !== write_only) {
|
} else if (def.value.write_only !== write_only) {
|
||||||
def.value.write_only = write_only;
|
def.value.write_only = write_only;
|
||||||
}
|
}
|
||||||
@@ -8139,7 +8138,7 @@ merge(Compressor.prototype, {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var insert, in_loop, scope;
|
var arg_used, insert, in_loop, scope;
|
||||||
if (replacing && can_inject_symbols()) {
|
if (replacing && can_inject_symbols()) {
|
||||||
fn._squeezed = true;
|
fn._squeezed = true;
|
||||||
if (exp !== fn) fn.parent_scope = exp.scope;
|
if (exp !== fn) fn.parent_scope = exp.scope;
|
||||||
@@ -8453,8 +8452,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var inline = compressor.option("inline");
|
var inline = compressor.option("inline");
|
||||||
var used = Object.create(defined);
|
arg_used = Object.create(defined);
|
||||||
if (!can_inject_args(defined, used, inline >= 2 && safe_to_inject)) return false;
|
if (!can_inject_args(defined, arg_used, inline >= 2 && safe_to_inject)) return false;
|
||||||
|
var used = Object.create(arg_used);
|
||||||
if (!can_inject_vars(defined, used, inline >= 3 && safe_to_inject)) return false;
|
if (!can_inject_vars(defined, used, inline >= 3 && safe_to_inject)) return false;
|
||||||
return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
|
return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
|
||||||
}
|
}
|
||||||
@@ -8558,10 +8558,7 @@ merge(Compressor.prototype, {
|
|||||||
name.thedef = redef;
|
name.thedef = redef;
|
||||||
}
|
}
|
||||||
append_var(decls, expressions, name, var_def.value);
|
append_var(decls, expressions, name, var_def.value);
|
||||||
if (in_loop && all(fn.argnames, function(argname) {
|
if (in_loop && !HOP(arg_used, name.name)) {
|
||||||
if (argname instanceof AST_DefaultValue) argname = argname.name;
|
|
||||||
return argname.name != name.name;
|
|
||||||
})) {
|
|
||||||
var def = fn.variables.get(name.name);
|
var def = fn.variables.get(name.name);
|
||||||
var sym = make_node(AST_SymbolRef, name, name);
|
var sym = make_node(AST_SymbolRef, name, name);
|
||||||
def.references.push(sym);
|
def.references.push(sym);
|
||||||
|
|||||||
@@ -2356,3 +2356,31 @@ issue_4504: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4508: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
(function f([ a ]) {
|
||||||
|
var a = console.log(a) && b, b = null;
|
||||||
|
})([ "PASS" ]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
[ [ a ] ] = [ [ "PASS" ] ],
|
||||||
|
b = void 0,
|
||||||
|
a = console.log(a) && b,
|
||||||
|
b = null,
|
||||||
|
void 0;
|
||||||
|
var a, b;
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2669,8 +2669,7 @@ issue_3956: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var c, d;
|
var d;
|
||||||
c += 0,
|
|
||||||
console.log(NaN),
|
console.log(NaN),
|
||||||
d = 1 ^ console.log(1),
|
d = 1 ^ console.log(1),
|
||||||
console.log(d);
|
console.log(d);
|
||||||
@@ -2703,13 +2702,13 @@ issue_3962_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 0;
|
var a = 0;
|
||||||
a = (function(c) {
|
(function(c) {
|
||||||
do {
|
do {
|
||||||
console;
|
console;
|
||||||
0..toString();
|
0..toString();
|
||||||
} while (0);
|
} while (0);
|
||||||
if (c) console.log("PASS");
|
if (c) console.log("PASS");
|
||||||
}(1), 0);
|
})(1);
|
||||||
void 0;
|
void 0;
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -2736,13 +2735,13 @@ issue_3962_2: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 0;
|
var a = 0;
|
||||||
a = (function(c) {
|
(function(c) {
|
||||||
do {
|
do {
|
||||||
console;
|
console;
|
||||||
0..toString();
|
0..toString();
|
||||||
} while (0);
|
} while (0);
|
||||||
if (c) console.log("PASS");
|
if (c) console.log("PASS");
|
||||||
}(1), 0);
|
})(1);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
@@ -2799,7 +2798,9 @@ issue_4017: {
|
|||||||
var a = 0;
|
var a = 0;
|
||||||
console.log(function() {
|
console.log(function() {
|
||||||
c &= 0;
|
c &= 0;
|
||||||
var c = (a++, A = a, 0);
|
var c;
|
||||||
|
a++,
|
||||||
|
A = a;
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
|
|||||||
Reference in New Issue
Block a user