Skip to content

Commit

Permalink
fix corner case in reduce_vars (#3378)
Browse files Browse the repository at this point in the history
fixes #3377
  • Loading branch information
alexlamsl committed Apr 24, 2019
1 parent a84beaf commit dafed54
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/compress.js
Expand Up @@ -744,7 +744,7 @@ merge(Compressor.prototype, {
d.fixed = false;
} else if (d.fixed) {
value = this.fixed_value();
if (value instanceof AST_Lambda && recursive_ref(tw, d)) {
if (recursive_ref(tw, d)) {
d.recursive_refs++;
} else if (value && ref_once(tw, compressor, d)) {
d.single_use = value instanceof AST_Lambda && !value.pinned()
Expand Down Expand Up @@ -2603,9 +2603,9 @@ merge(Compressor.prototype, {
}

function convert_to_predicate(obj) {
for (var key in obj) {
Object.keys(obj).forEach(function(key) {
obj[key] = makePredicate(obj[key]);
}
});
}

var object_fns = [
Expand Down
18 changes: 18 additions & 0 deletions test/compress/reduce_vars.js
Expand Up @@ -6737,3 +6737,21 @@ drop_side_effect_free: {
}
expect_stdout: "123"
}

issue_3377: {
options = {
reduce_vars: true,
unused: true,
}
input: {
console.log(function f() {
return f[0], (f = 42);
}());
}
expect: {
console.log(function f() {
return f[0], (f = 42);
}());
}
expect_stdout: "42"
}

0 comments on commit dafed54

Please sign in to comment.