fix corner cases in inline (#5241)

fixes #5239
fixes #5240
This commit is contained in:
Alex Lam S.L
2021-12-26 08:39:06 +08:00
committed by GitHub
parent e1013bd56d
commit 835d130ccf
3 changed files with 169 additions and 8 deletions

View File

@@ -7135,3 +7135,105 @@ issue_5237: {
"undefined",
]
}
issue_5239: {
options = {
functions: true,
inline: true,
reduce_vars: true,
unused: true,
}
input: {
(function() {
(function(f) {
var a = 42, f = function() {};
while (console.log(f.p || a++));
})();
})();
}
expect: {
(function() {
var f = void 0;
var a = 42, f = function() {};
while (console.log(f.p || a++));
return;
})();
}
expect_stdout: "42"
}
issue_5240_1: {
options = {
inline: true,
}
input: {
function f() {
try {
throw "FAIL 1";
} catch (e) {
return function() {
if (console) {
console.log(e);
var e = "FAIL 2";
}
}();
}
}
f();
}
expect: {
function f() {
try {
throw "FAIL 1";
} catch (e) {
return function() {
if (console) {
console.log(e);
var e = "FAIL 2";
}
}();
}
}
f();
}
expect_stdout: "undefined"
}
issue_5240_2: {
options = {
inline: true,
}
input: {
function f() {
try {
throw "FAIL 1";
} catch (e) {
{
return function() {
if (console) {
console.log(e);
var e = "FAIL 2";
}
}();
}
}
}
f();
}
expect: {
function f() {
try {
throw "FAIL 1";
} catch (e) {
return function() {
if (console) {
console.log(e);
var e = "FAIL 2";
}
}();
}
}
f();
}
expect_stdout: "undefined"
}

View File

@@ -1747,3 +1747,48 @@ issue_4985: {
expect_stdout: "undefined"
node_version: ">=4"
}
issue_5240: {
options = {
inline: true,
}
input: {
"use strict";
function f() {
if (console) {
let g = function() {
e;
}, e;
(function() {
if (console) {
console.log(e);
var e = "FAIL";
}
})(console.log(e));
}
}
f();
}
expect: {
"use strict";
function f() {
if (console) {
let g = function() {
e;
}, e;
(function() {
if (console) {
console.log(e);
var e = "FAIL";
}
})(console.log(e));
}
}
f();
}
expect_stdout: [
"undefined",
"undefined",
]
node_version: ">=4"
}