diff options
-rw-r--r-- | lib/scope.js | 18 | ||||
-rw-r--r-- | test/compress/ie8.js | 108 |
2 files changed, 115 insertions, 11 deletions
diff --git a/lib/scope.js b/lib/scope.js index 5e114417..f78b4c5e 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -198,24 +198,20 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) { } if (node instanceof AST_SymbolLambda) { var def = node.thedef; - if (def.orig.length == 1) { - redefine(node, node.scope.parent_scope); - node.thedef.init = def.init; - } + redefine(node, node.scope.parent_scope); + node.thedef.init = def.init; return true; } })); function redefine(node, scope) { var name = node.name; - var refs = node.thedef.references; - var def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node); - refs.forEach(function(ref) { - ref.thedef = def; - ref.reference(options); + var old_def = node.thedef; + var new_def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node); + old_def.orig.concat(old_def.references).forEach(function(node) { + node.thedef = new_def; + node.reference(options); }); - node.thedef = def; - node.reference(options); } }); diff --git a/test/compress/ie8.js b/test/compress/ie8.js index dd9bae47..f98033e0 100644 --- a/test/compress/ie8.js +++ b/test/compress/ie8.js @@ -861,3 +861,111 @@ issue_3215_4: { } expect_stdout: "PASS" } + +issue_3355_1: { + mangle = { + ie8: false, + } + input: { + (function f() { + var f; + })(); + (function g() { + })(); + console.log(typeof f === typeof g); + } + expect: { + (function o() { + var o; + })(); + (function o() { + })(); + console.log(typeof f === typeof g); + } + expect_stdout: "true" +} + +issue_3355_2: { + mangle = { + ie8: true, + } + input: { + (function f() { + var f; + })(); + (function g() { + })(); + console.log(typeof f === typeof g); + } + expect: { + (function f() { + var f; + })(); + (function g() { + })(); + console.log(typeof f === typeof g); + } + expect_stdout: "true" +} + +issue_3355_3: { + mangle = { + ie8: false, + } + input: { + !function(a) { + "aaaaaaaaaa"; + a(); + var b = function c() { + var c = 42; + console.log("FAIL"); + }; + }(function() { + console.log("PASS"); + }); + } + expect: { + !function(a) { + "aaaaaaaaaa"; + a(); + var o = function a() { + var a = 42; + console.log("FAIL"); + }; + }(function() { + console.log("PASS"); + }); + } + expect_stdout: "PASS" +} + +issue_3355_4: { + mangle = { + ie8: true, + } + input: { + !function(a) { + "aaaaaaaaaa"; + a(); + var b = function c() { + var c = 42; + console.log("FAIL"); + }; + }(function() { + console.log("PASS"); + }); + } + expect: { + !function(a) { + "aaaaaaaaaa"; + a(); + var o = function n() { + var n = 42; + console.log("FAIL"); + }; + }(function() { + console.log("PASS"); + }); + } + expect_stdout: "PASS" +} |