fix corner case in ie8 & mangle (#3476)

fixes #3475
This commit is contained in:
Alex Lam S.L
2019-10-15 14:18:12 +08:00
committed by GitHub
parent d3d1d11926
commit f86f615d83
3 changed files with 141 additions and 9 deletions

View File

@@ -201,7 +201,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
} }
if (node instanceof AST_SymbolLambda) { if (node instanceof AST_SymbolLambda) {
var def = node.thedef; var def = node.thedef;
redefine(node, node.scope.parent_scope); redefine(node, node.scope.parent_scope.resolve());
node.thedef.init = def.init; node.thedef.init = def.init;
return true; return true;
} }

View File

@@ -1189,3 +1189,135 @@ issue_3473_ie8_toplevel: {
} }
expect_stdout: "100 10 1" expect_stdout: "100 10 1"
} }
issue_3475: {
rename = true
mangle = {
ie8: false,
toplevel: false,
}
input: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (b) {
(function f() {
a = "PASS";
})();
}
console.log(a);
}
expect: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (o) {
(function o() {
a = "PASS";
})();
}
console.log(a);
}
expect_stdout: "PASS"
}
issue_3475_ie8: {
rename = true
mangle = {
ie8: true,
toplevel: false,
}
input: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (b) {
(function f() {
a = "PASS";
})();
}
console.log(a);
}
expect: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (b) {
(function f() {
a = "PASS";
})();
}
console.log(a);
}
expect_stdout: "PASS"
}
issue_3475_toplevel: {
rename = true
mangle = {
ie8: false,
toplevel: true,
}
input: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (b) {
(function f() {
a = "PASS";
})();
}
console.log(a);
}
expect: {
"ooooo ddddd";
var d = "FAIL";
try {
throw 42;
} catch (o) {
(function o() {
d = "PASS";
})();
}
console.log(d);
}
expect_stdout: "PASS"
}
issue_3475_ie8_toplevel: {
rename = true
mangle = {
ie8: true,
toplevel: true,
}
input: {
"ooooo ddddd";
var a = "FAIL";
try {
throw 42;
} catch (b) {
(function f() {
a = "PASS";
})();
}
console.log(a);
}
expect: {
"ooooo ddddd";
var o = "FAIL";
try {
throw 42;
} catch (d) {
(function c() {
o = "PASS";
})();
}
console.log(o);
}
expect_stdout: "PASS"
}

View File

@@ -579,7 +579,7 @@ function_do_catch_ie8: {
console.log(b, c); console.log(b, c);
} }
expect: { expect: {
var t = 1, u = 1, y = 0; var u = 1, y = 1, a = 0;
function c(c) { function c(c) {
var d; var d;
do { do {
@@ -587,7 +587,7 @@ function_do_catch_ie8: {
try { try {
var e = void 0; var e = void 0;
} catch (i) { } catch (i) {
--t && w("ddddddddeeeeeeegggggggggiiiiilllllllnnnnntuuuuuuuuyyyyyyy"); --u && w("ddddddddeeeeeeegggggggggiiiiilllllllnnnnntuuuuuuuuyyyyyyy");
0; 0;
0; 0;
0; 0;
@@ -596,18 +596,18 @@ function_do_catch_ie8: {
d[1]; d[1];
} catch (l) { } catch (l) {
var g; var g;
switch(function x() { switch (function n() {
y++; a++;
}()) { }()) {
case e + --g: case e + --g:
} }
} }
} catch (n) {} } catch (t) {}
} while (--d); } while (--d);
u--; y--;
} }
c(); c();
console.log(u, y); console.log(y, a);
} }
expect_stdout: "0 1" expect_stdout: "0 1"
} }