fix corner case in inline (#5664)

fixes #5662
This commit is contained in:
Alex Lam S.L
2022-09-17 01:54:54 +01:00
committed by GitHub
parent e0b302d651
commit 001f6f9719
3 changed files with 44 additions and 8 deletions

View File

@@ -3586,3 +3586,36 @@ issue_5531_3: {
expect_stdout: "foo"
node_version: ">=16"
}
issue_5662: {
options = {
inline: true,
reduce_vars: true,
}
input: {
console.log(new (function() {
var g = function(a) {
return a;
};
return class {
h(b) {
return g(b);
}
};
}())().h("PASS"));
}
expect: {
console.log(new (function() {
var g = function(a) {
return a;
};
return class {
h(b) {
return g(b);
}
};
}())().h("PASS"));
}
expect_stdout: "PASS"
node_version: ">=6"
}

View File

@@ -466,7 +466,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
}
}
else if (node instanceof U.AST_VarDef) {
if (node.value && !(parent instanceof U.AST_Const)) {
if (node.value && !(node.name instanceof U.AST_Destructured || parent instanceof U.AST_Const)) {
node.start._permute++;
CHANGED = true;
return new U.AST_VarDef({