fix scope assignment to switch expressions (#5826)

fixes #5787
fixes #5792
This commit is contained in:
Alex Lam S.L
2024-06-05 22:05:16 +03:00
committed by GitHub
parent ffe0fe7762
commit 34b6143306
4 changed files with 115 additions and 0 deletions

View File

@@ -739,3 +739,55 @@ issue_3480_ie8_toplevel: {
}
expect_stdout: "PASS"
}
issue_5787_1: {
rename = true
input: {
console.log(function() {
const a = 42;
switch (a) {
case 42:
const a = "PASS";
return a;
}
}());
}
expect: {
console.log(function() {
const a = 42;
switch (a) {
case 42:
const a = "PASS";
return a;
}
}());
}
expect_stdout: true
}
issue_5787_2: {
rename = true
input: {
console.log(function() {
let a = 42;
switch (a) {
case 42:
// Node.js v4 (vm): SyntaxError: Identifier 'a' has already been declared
let a = "PASS";
return a;
}
}());
}
expect: {
console.log(function() {
let a = 42;
switch (a) {
case 42:
let b = "PASS";
return b;
}
}());
}
expect_stdout: "PASS"
node_version: ">=6"
}