Skip to content

Commit

Permalink
fix corner case in ie8 (#3487)
Browse files Browse the repository at this point in the history
fixes #3486
  • Loading branch information
alexlamsl committed Oct 16, 2019
1 parent 8ff9a3c commit 1549db7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/scope.js
Expand Up @@ -194,15 +194,19 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
if (node instanceof AST_SymbolCatch) {
var scope = node.thedef.defun;
if (scope.name instanceof AST_SymbolLambda && scope.name.name == node.name) {
scope = scope.parent_scope;
scope = scope.parent_scope.resolve();
}
redefine(node, scope);
return true;
}
if (node instanceof AST_SymbolLambda) {
var def = node.thedef;
redefine(node, node.scope.parent_scope.resolve());
if (def.init) node.thedef.init = def.init;
if (typeof node.thedef.init !== "undefined") {
node.thedef.init = false;
} else if (def.init) {
node.thedef.init = def.init;
}
return true;
}
}));
Expand Down
46 changes: 46 additions & 0 deletions test/compress/ie8.js
Expand Up @@ -1841,3 +1841,49 @@ issue_3484_2_ie8_toplevel: {
}
expect_stdout: "number number"
}

issue_3486: {
options = {
conditionals: true,
ie8: false,
reduce_vars: true,
}
input: {
(function a() {
(function a(a) {
console.log(a ? "FAIL" : "PASS");
})();
})();
}
expect: {
(function a() {
(function a(a) {
console.log(a ? "FAIL" : "PASS");
})();
})();
}
expect_stdout: "PASS"
}

issue_3486_ie8: {
options = {
conditionals: true,
ie8: true,
reduce_vars: true,
}
input: {
(function a() {
(function a(a) {
console.log(a ? "FAIL" : "PASS");
})();
})();
}
expect: {
(function a() {
(function a(a) {
console.log(a ? "FAIL" : "PASS");
})();
})();
}
expect_stdout: "PASS"
}

0 comments on commit 1549db7

Please sign in to comment.