@@ -3643,7 +3643,7 @@ merge(Compressor.prototype, {
|
||||
stat.init = stat.init.definitions[0].name.convert_symbol(AST_SymbolRef, function(ref, name) {
|
||||
defns.push(make_node(AST_VarDef, name, {
|
||||
name: name,
|
||||
value: null
|
||||
value: null,
|
||||
}));
|
||||
name.definition().references.push(ref);
|
||||
});
|
||||
@@ -7007,6 +7007,7 @@ merge(Compressor.prototype, {
|
||||
var value = node.value.drop_side_effect_free(compressor);
|
||||
if (!value) return null;
|
||||
log(node.name, "Side effects in default value of unused variable {name}");
|
||||
node.name.__unused = null;
|
||||
node.value = value;
|
||||
}
|
||||
return node;
|
||||
@@ -9646,7 +9647,6 @@ merge(Compressor.prototype, {
|
||||
fn.each_argname(function(arg) {
|
||||
if (abort) return;
|
||||
if (arg.__unused) return;
|
||||
if (arg instanceof AST_DefaultValue) arg = arg.name;
|
||||
if (!safe_to_inject || var_exists(defined, arg.name)) return abort = true;
|
||||
used[arg.name] = true;
|
||||
if (in_loop) in_loop.push(arg.definition());
|
||||
@@ -9720,22 +9720,22 @@ merge(Compressor.prototype, {
|
||||
|
||||
function append_var(decls, expressions, name, value) {
|
||||
var def = name.definition();
|
||||
scope.variables.set(name.name, def);
|
||||
scope.enclosed.push(def);
|
||||
if (!scope.var_names()[name.name]) {
|
||||
scope.var_names()[name.name] = true;
|
||||
decls.push(make_node(AST_VarDef, name, {
|
||||
name: name,
|
||||
value: null
|
||||
value: null,
|
||||
}));
|
||||
}
|
||||
scope.variables.set(name.name, def);
|
||||
scope.enclosed.push(def);
|
||||
if (!value) return;
|
||||
var sym = make_node(AST_SymbolRef, name, name);
|
||||
def.references.push(sym);
|
||||
expressions.push(make_node(AST_Assign, self, {
|
||||
operator: "=",
|
||||
left: sym,
|
||||
right: value
|
||||
right: value,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -1416,6 +1416,7 @@ issue_4502_1: {
|
||||
expect: {
|
||||
(function() {
|
||||
var a = "PASS";
|
||||
void 0,
|
||||
console.log(a),
|
||||
a++,
|
||||
void 0;
|
||||
@@ -1439,6 +1440,7 @@ issue_4502_2: {
|
||||
expect: {
|
||||
(function() {
|
||||
var a = "PASS";
|
||||
void 0,
|
||||
console.log(a),
|
||||
a++,
|
||||
void 0;
|
||||
@@ -1754,3 +1756,78 @@ issue_4994: {
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5057_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
inline: true,
|
||||
sequences: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
var a = 42;
|
||||
(function() {
|
||||
var b = function(c = (console.log("foo"), b = a)) {
|
||||
a && console.log("bar");
|
||||
}();
|
||||
})();
|
||||
}
|
||||
expect: {
|
||||
var a = 42;
|
||||
console.log("foo"),
|
||||
void (a && console.log("bar"));
|
||||
}
|
||||
expect_stdout: [
|
||||
"foo",
|
||||
"bar",
|
||||
]
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5057_2: {
|
||||
options = {
|
||||
inline: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function f(a) {
|
||||
(function(b = console.log("FAIL")) {})(a);
|
||||
})(42);
|
||||
console.log(typeof b);
|
||||
}
|
||||
expect: {
|
||||
(function(a) {
|
||||
[ b = console.log("FAIL") ] = [ a ],
|
||||
void 0;
|
||||
var b;
|
||||
})(42);
|
||||
console.log(typeof b);
|
||||
}
|
||||
expect_stdout: "undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5057_3: {
|
||||
options = {
|
||||
inline: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(a) {
|
||||
(function f(b) {
|
||||
(function(a = console.log("FAIL 1")) {})(b);
|
||||
console.log(a);
|
||||
})("FAIL 2");
|
||||
})("PASS");
|
||||
}
|
||||
expect: {
|
||||
(function(a) {
|
||||
(function(b) {
|
||||
(function(a = console.log("FAIL 1")) {})(b);
|
||||
console.log(a);
|
||||
})("FAIL 2");
|
||||
})("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user