fix corner cases in collapse_vars (#4249)

fixes #4248
This commit is contained in:
Alex Lam S.L
2020-10-30 02:04:23 +00:00
committed by GitHub
parent 79e5c3f564
commit 5d12abc41b
4 changed files with 110 additions and 13 deletions

View File

@@ -8577,3 +8577,28 @@ issue_4242: {
}
expect_stdout: "undefined"
}
issue_4248: {
options = {
collapse_vars: true,
}
input: {
var a = 0;
try {
a = 1;
b[1];
} catch (e) {
console.log(a);
}
}
expect: {
var a = 0;
try {
a = 1;
b[1];
} catch (e) {
console.log(a);
}
}
expect_stdout: "1"
}

View File

@@ -1104,3 +1104,34 @@ issue_4245: {
}
expect_stdout: true
}
issue_4248: {
options = {
collapse_vars: true,
}
input: {
var a = "FAIL";
try {
(function() {
a = "PASS";
b[a];
const b = 0;
})();
} catch (e) {
console.log(a);
}
}
expect: {
var a = "FAIL";
try {
(function() {
a = "PASS";
b[a];
const b = 0;
})();
} catch (e) {
console.log(a);
}
}
expect_stdout: "PASS"
}

View File

@@ -916,3 +916,37 @@ issue_4245: {
expect_stdout: ReferenceError("a is not defined")
node_version: ">=4"
}
issue_4248: {
options = {
collapse_vars: true,
}
input: {
var a = "FAIL";
try {
(function() {
"use strict";
a = "PASS";
b[a];
let b;
})();
} catch (e) {
console.log(a);
}
}
expect: {
var a = "FAIL";
try {
(function() {
"use strict";
a = "PASS";
b[a];
let b;
})();
} catch (e) {
console.log(a);
}
}
expect_stdout: "PASS"
node_version: ">=4"
}