Skip to content

Commit 85968de

Browse files
authored
fix corner case in inline (#5088)
fixes #5087
1 parent a7e7865 commit 85968de

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

lib/compress.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9957,8 +9957,10 @@ merge(Compressor.prototype, {
99579957
}));
99589958

99599959
function process(ref, name) {
9960+
var def = name.definition();
9961+
def.references.push(ref);
99609962
var symbol = make_node(AST_SymbolVar, name, name);
9961-
name.definition().orig.push(symbol);
9963+
def.orig.push(symbol);
99629964
append_var(decls, expressions, symbol);
99639965
}
99649966
}

test/compress/destructured.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,3 +2998,62 @@ issue_5085_2: {
29982998
expect_stdout: "PASS"
29992999
node_version: ">=6"
30003000
}
3001+
3002+
issue_5087_1: {
3003+
options = {
3004+
collapse_vars: true,
3005+
inline: true,
3006+
properties: true,
3007+
sequences: true,
3008+
side_effects: true,
3009+
unused: true,
3010+
}
3011+
input: {
3012+
var a = "PASS";
3013+
(function() {
3014+
(function() {
3015+
(function([ b ]) {
3016+
b && console.log(b);
3017+
})([ a ]);
3018+
})();
3019+
})();
3020+
}
3021+
expect: {
3022+
var a = "PASS";
3023+
(function() {
3024+
var b;
3025+
(b = a) && console.log(b);
3026+
})();
3027+
}
3028+
expect_stdout: "PASS"
3029+
node_version: ">=6"
3030+
}
3031+
3032+
issue_5087_2: {
3033+
options = {
3034+
collapse_vars: true,
3035+
inline: true,
3036+
passes: 2,
3037+
properties: true,
3038+
reduce_vars: true,
3039+
sequences: true,
3040+
side_effects: true,
3041+
unused: true,
3042+
}
3043+
input: {
3044+
var a = "PASS";
3045+
(function() {
3046+
(function() {
3047+
(function([ b ]) {
3048+
b && console.log(b);
3049+
})([ a ]);
3050+
})();
3051+
})();
3052+
}
3053+
expect: {
3054+
var a = "PASS";
3055+
a && console.log(a);
3056+
}
3057+
expect_stdout: "PASS"
3058+
node_version: ">=6"
3059+
}

0 commit comments

Comments
 (0)