fix pre-existing issue

- chained assignment
This commit is contained in:
alexlamsl 2017-04-18 05:46:25 +08:00
parent 79d533a560
commit 2bdf3dc1c0
2 changed files with 24 additions and 1 deletions

View File

@ -297,7 +297,9 @@ merge(Compressor.prototype, {
&& node.operator == "="
&& node.left instanceof AST_SymbolRef) {
var d = node.left.definition();
if (HOP(safe_ids, d.id) && safe_to_assign(d, node.right)) {
if (HOP(safe_ids, d.id)
&& safe_to_read(d)
&& safe_to_assign(d, node.right)) {
d.references.push(node.left);
d.fixed = function() {
return node.right;

View File

@ -2110,6 +2110,27 @@ var_assign_5: {
expect_stdout: "2 undefined"
}
var_assign_6: {
options = {
evaluate: true,
reduce_vars: true,
unused: true,
}
input: {
!function() {
var a = function(){}(a = 1);
console.log(a);
}();
}
expect: {
!function() {
var a = function(){}(a = 1);
console.log(a);
}();
}
expect_stdout: "undefined"
}
immutable: {
options = {
evaluate: true,