}
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);
}
});
}
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"
+}