fix corner cases with block-scoped functions (#4695)

This commit is contained in:
Alex Lam S.L
2021-02-26 20:16:14 +00:00
committed by GitHub
parent ea52339502
commit ac26993b5a
6 changed files with 271 additions and 20 deletions

View File

@@ -1454,3 +1454,47 @@ issue_4689: {
expect_stdout: "PASS"
node_version: ">=4"
}
issue_4691: {
options = {
if_return: true,
toplevel: true,
}
input: {
function A() {}
A.prototype.f = function() {
if (!this)
return;
const a = "PA";
function g(b) {
h(a + b);
}
[ "SS" ].forEach(function(c) {
g(c);
});
};
function h(d) {
console.log(d);
}
new A().f();
}
expect: {
function A() {}
A.prototype.f = function() {
if (this) {
const a = "PA";
[ "SS" ].forEach(function(c) {
g(c);
});
function g(b) {
h(a + b);
}
}
};
function h(d) {
console.log(d);
}
new A().f();
}
expect_stdout: "PASS"
}