Skip to content

Commit

Permalink
fix corner case in inline (#5088)
Browse files Browse the repository at this point in the history
fixes #5087
  • Loading branch information
alexlamsl committed Jul 19, 2021
1 parent a7e7865 commit 85968de
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -9957,8 +9957,10 @@ merge(Compressor.prototype, {
}));

function process(ref, name) {
var def = name.definition();
def.references.push(ref);
var symbol = make_node(AST_SymbolVar, name, name);
name.definition().orig.push(symbol);
def.orig.push(symbol);
append_var(decls, expressions, symbol);
}
}
Expand Down
59 changes: 59 additions & 0 deletions test/compress/destructured.js
Original file line number Diff line number Diff line change
Expand Up @@ -2998,3 +2998,62 @@ issue_5085_2: {
expect_stdout: "PASS"
node_version: ">=6"
}

issue_5087_1: {
options = {
collapse_vars: true,
inline: true,
properties: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function() {
(function() {
(function([ b ]) {
b && console.log(b);
})([ a ]);
})();
})();
}
expect: {
var a = "PASS";
(function() {
var b;
(b = a) && console.log(b);
})();
}
expect_stdout: "PASS"
node_version: ">=6"
}

issue_5087_2: {
options = {
collapse_vars: true,
inline: true,
passes: 2,
properties: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function() {
(function() {
(function([ b ]) {
b && console.log(b);
})([ a ]);
})();
})();
}
expect: {
var a = "PASS";
a && console.log(a);
}
expect_stdout: "PASS"
node_version: ">=6"
}

0 comments on commit 85968de

Please sign in to comment.