fix corner cases in sequences (#4690)

fixes #4689
This commit is contained in:
Alex Lam S.L
2021-02-25 04:48:40 +00:00
committed by GitHub
parent 822b1da5d2
commit 6d7ab63a66
3 changed files with 41 additions and 3 deletions

View File

@@ -3118,7 +3118,7 @@ merge(Compressor.prototype, {
} }
} }
} else if (stat instanceof AST_ForIn) { } else if (stat instanceof AST_ForIn) {
stat.object = cons_seq(stat.object); if (!is_lexical_definition(stat.init)) stat.object = cons_seq(stat.object);
} else if (stat instanceof AST_If) { } else if (stat instanceof AST_If) {
stat.condition = cons_seq(stat.condition); stat.condition = cons_seq(stat.condition);
} else if (stat instanceof AST_Switch) { } else if (stat instanceof AST_Switch) {

View File

@@ -1434,3 +1434,23 @@ issue_4527: {
} }
expect_stdout: "aaaa" expect_stdout: "aaaa"
} }
issue_4689: {
options = {
sequences: true,
}
input: {
"use strict";
var a = "PASS";
console.log(a);
for (const a in 42);
}
expect: {
"use strict";
var a = "PASS";
console.log(a);
for (const a in 42);
}
expect_stdout: "PASS"
node_version: ">=4"
}

View File

@@ -1319,7 +1319,6 @@ issue_4531_2: {
toplevel: true, toplevel: true,
} }
input: { input: {
"use strict";
var a = console; var a = console;
console.log(typeof a, function a() { console.log(typeof a, function a() {
let { [console]: a } = 0 && a; let { [console]: a } = 0 && a;
@@ -1328,7 +1327,6 @@ issue_4531_2: {
}()); }());
} }
expect: { expect: {
"use strict";
var o = console; var o = console;
console.log(typeof o, function o() { console.log(typeof o, function o() {
let { [console]: o } = 0; let { [console]: o } = 0;
@@ -1339,3 +1337,23 @@ issue_4531_2: {
expect_stdout: "object undefined" expect_stdout: "object undefined"
node_version: ">=6" node_version: ">=6"
} }
issue_4689: {
options = {
sequences: true,
}
input: {
"use strict";
var a = "PASS";
console.log(a);
for (let a in 42);
}
expect: {
"use strict";
var a = "PASS";
console.log(a);
for (let a in 42);
}
expect_stdout: "PASS"
node_version: ">=4"
}