Skip to content

Commit

Permalink
fix corner case in ie8 & mangle (#3476)
Browse files Browse the repository at this point in the history
fixes #3475
  • Loading branch information
alexlamsl committed Oct 15, 2019
1 parent d3d1d11 commit f86f615
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/scope.js
Expand Up @@ -201,7 +201,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
}
if (node instanceof AST_SymbolLambda) {
var def = node.thedef;
redefine(node, node.scope.parent_scope);
redefine(node, node.scope.parent_scope.resolve());
node.thedef.init = def.init;
return true;
}
Expand Down
132 changes: 132 additions & 0 deletions test/compress/ie8.js
Expand Up @@ -1189,3 +1189,135 @@ issue_3473_ie8_toplevel: {
}
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"
}
16 changes: 8 additions & 8 deletions test/compress/rename.js
Expand Up @@ -579,15 +579,15 @@ function_do_catch_ie8: {
console.log(b, c);
}
expect: {
var t = 1, u = 1, y = 0;
var u = 1, y = 1, a = 0;
function c(c) {
var d;
do {
try {
try {
var e = void 0;
} catch (i) {
--t && w("ddddddddeeeeeeegggggggggiiiiilllllllnnnnntuuuuuuuuyyyyyyy");
--u && w("ddddddddeeeeeeegggggggggiiiiilllllllnnnnntuuuuuuuuyyyyyyy");
0;
0;
0;
Expand All @@ -596,18 +596,18 @@ function_do_catch_ie8: {
d[1];
} catch (l) {
var g;
switch(function x() {
y++;
switch (function n() {
a++;
}()) {
case e + --g:
case e + --g:
}
}
} catch (n) {}
} catch (t) {}
} while (--d);
u--;
y--;
}
c();
console.log(u, y);
console.log(y, a);
}
expect_stdout: "0 1"
}

0 comments on commit f86f615

Please sign in to comment.