Skip to content

Commit

Permalink
fix corner case in properties (#3390)
Browse files Browse the repository at this point in the history
fixes #3389
  • Loading branch information
alexlamsl committed Apr 29, 2019
1 parent 413bbe0 commit c37a8e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/compress.js
Expand Up @@ -6067,7 +6067,7 @@ merge(Compressor.prototype, {
}
}
var parent = compressor.parent();
if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
if (compressor.option("reduce_vars") && is_lhs(compressor.self(), parent) !== compressor.self()) {
var def = self.definition();
var fixed = self.fixed_value();
var single_use = def.single_use && !(parent instanceof AST_Call && parent.is_expr_pure(compressor));
Expand Down Expand Up @@ -6689,7 +6689,7 @@ merge(Compressor.prototype, {
return sym;
}
}
if (is_lhs(self, compressor.parent())) return self;
if (is_lhs(compressor.self(), compressor.parent())) return self;
if (key !== prop) {
var sub = self.flatten_object(property, compressor);
if (sub) {
Expand Down Expand Up @@ -6787,7 +6787,7 @@ merge(Compressor.prototype, {
col: self.start.col
});
}
if (is_lhs(self, compressor.parent())) return self;
if (is_lhs(compressor.self(), compressor.parent())) return self;
if (compressor.option("unsafe_proto")
&& self.expression instanceof AST_Dot
&& self.expression.property == "prototype") {
Expand Down
26 changes: 26 additions & 0 deletions test/compress/properties.js
Expand Up @@ -1862,3 +1862,29 @@ join_expr: {
}
expect_stdout: "PASS"
}

issue_3389: {
options = {
evaluate: true,
properties: true,
reduce_vars: true,
unsafe: true,
}
input: {
(function() {
var a = "PASS";
if (delete b)
b = a[null] = 42;
console.log(a);
})();
}
expect: {
(function() {
var a = "PASS";
if (delete b)
b = a.null = 42;
console.log(a);
})();
}
expect_stdout: "PASS"
}

0 comments on commit c37a8e9

Please sign in to comment.