@@ -6943,13 +6943,16 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (!drop_sym || !drop_vars || sym.id in in_use_ids) {
|
if (!drop_sym || !drop_vars || sym.id in in_use_ids) {
|
||||||
var index;
|
var index;
|
||||||
if (value && ((index = indexOf_assign(sym, def)) < 0 || self_assign(value.tail_node()))) {
|
if (value && ((index = indexOf_assign(sym, def)) < 0 || self_assign(value.tail_node()))) {
|
||||||
value = value.drop_side_effect_free(compressor);
|
|
||||||
if (value) {
|
|
||||||
AST_Node.warn("Side effects in definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
|
||||||
side_effects.push(value);
|
|
||||||
}
|
|
||||||
def = def.clone();
|
def = def.clone();
|
||||||
def.value = value = null;
|
value = value.drop_side_effect_free(compressor);
|
||||||
|
if (value) AST_Node.warn("Side effects in definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
|
if (node instanceof AST_Const) {
|
||||||
|
def.value = value || make_node(AST_Number, def, { value: 0 });
|
||||||
|
} else {
|
||||||
|
def.value = null;
|
||||||
|
if (value) side_effects.push(value);
|
||||||
|
}
|
||||||
|
value = null;
|
||||||
if (index >= 0) assign_in_use[sym.id][index] = def;
|
if (index >= 0) assign_in_use[sym.id][index] = def;
|
||||||
}
|
}
|
||||||
var old_def, fn;
|
var old_def, fn;
|
||||||
|
|||||||
@@ -1843,3 +1843,16 @@ issue_5319: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5338: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
const a = a;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
const a = a;
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
@@ -2006,3 +2006,20 @@ issue_5319: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5338: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
let a = a;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
a;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
expect_stdout: ReferenceError("a is not defined")
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user