Skip to content

Commit

Permalink
fix corner case in collapse_vars (#4917)
Browse files Browse the repository at this point in the history
fixes #4916
  • Loading branch information
alexlamsl committed May 7, 2021
1 parent ac1f7d6 commit ee9ceb7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -1490,7 +1490,7 @@ merge(Compressor.prototype, {
lhs = lhs.fixed_value();
}
if (!lhs) return true;
if (lhs.is_constant()) return true;
if (lhs.tail_node().is_constant()) return true;
return is_lhs_read_only(lhs, compressor);
}
if (lhs instanceof AST_SymbolRef) {
Expand Down
26 changes: 26 additions & 0 deletions test/compress/default-values.js
Expand Up @@ -1703,3 +1703,29 @@ issue_4854: {
expect_stdout: "undefined"
node_version: ">=6"
}

issue_4916: {
options = {
collapse_vars: true,
pure_getters: "strict",
reduce_vars: true,
}
input: {
var log = console.log;
(function(b = "foo") {
b.value = "FAIL";
b;
log(b.value);
})();
}
expect: {
var log = console.log;
(function(b = "foo") {
b.value = "FAIL";
b;
log(b.value);
})();
}
expect_stdout: "undefined"
node_version: ">=6"
}

0 comments on commit ee9ceb7

Please sign in to comment.