Skip to content

Commit

Permalink
handle modifications to this correctly (#3036)
Browse files Browse the repository at this point in the history
fixes #3032
  • Loading branch information
alexlamsl committed Mar 30, 2018
1 parent 9f9db50 commit 06b9894
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -1052,6 +1052,7 @@ merge(Compressor.prototype, {
&& (side_effects || node.expression.may_throw_on_access(compressor))
|| node instanceof AST_SymbolRef
&& (symbol_in_lvalues(node) || side_effects && may_modify(node))
|| node instanceof AST_This && symbol_in_lvalues(node)
|| node instanceof AST_VarDef && node.value
&& (node.name.name in lvalues || side_effects && may_modify(node.name))
|| (sym = is_lhs(node.left, node))
Expand Down
24 changes: 24 additions & 0 deletions test/compress/collapse_vars.js
Expand Up @@ -5303,3 +5303,27 @@ issue_2974: {
}
expect_stdout: "1"
}

issue_3032: {
options = {
collapse_vars: true,
pure_getters: true,
}
input: {
console.log({
f: function() {
this.a = 42;
return [ this.a, !1 ];
}
}.f()[0]);
}
expect: {
console.log({
f: function() {
this.a = 42;
return [ this.a, !1 ];
}
}.f()[0]);
}
expect_stdout: "42"
}

0 comments on commit 06b9894

Please sign in to comment.