Skip to content

Commit

Permalink
fix corner case in side_effects (#3514)
Browse files Browse the repository at this point in the history
fixes #3512
  • Loading branch information
alexlamsl committed Oct 22, 2019
1 parent 02308a7 commit a53ab99
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Expand Up @@ -4196,7 +4196,7 @@ merge(Compressor.prototype, {
var left = this.left;
if (left instanceof AST_PropAccess) {
var expr = left.expression;
if (expr instanceof AST_Assign && !expr.may_throw_on_access(compressor)) {
if (expr instanceof AST_Assign && expr.operator == "=" && !expr.may_throw_on_access(compressor)) {
expr.write_only = "p";
}
if (compressor.has_directive("use strict") && expr.is_constant()) return this;
Expand Down
30 changes: 30 additions & 0 deletions test/compress/functions.js
Expand Up @@ -3340,3 +3340,33 @@ issue_3506_3: {
}
expect_stdout: "PASS"
}

issue_3512: {
options = {
collapse_vars: true,
pure_getters: "strict",
sequences: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function(b) {
(function() {
b <<= this || 1;
b.a = "FAIL";
})();
})();
console.log(a);
}
expect: {
var a = "PASS";
(function(b) {
(function() {
(b <<= this || 1).a = "FAIL";
})();
})(),
console.log(a);
}
expect_stdout: "PASS"
}

0 comments on commit a53ab99

Please sign in to comment.