Skip to content

Commit

Permalink
mangle unused nested AST_SymbolCatch correctly (#3038)
Browse files Browse the repository at this point in the history
fixes #3035
  • Loading branch information
alexlamsl committed Mar 30, 2018
1 parent 06b9894 commit fa32501
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/scope.js
Expand Up @@ -434,16 +434,19 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
var redef = def.redefined();
if (redef) {
redefined.push(def);
def.references.forEach(function(ref) {
ref.thedef = redef;
ref.reference(options);
ref.thedef = def;
});
reference(node.argname);
def.references.forEach(reference);
}
descend();
if (!redef) mangle(def);
return true;
}

function reference(sym) {
sym.thedef = redef;
sym.reference(options);
sym.thedef = def;
}
});
this.walk(tw);
redefined.forEach(mangle);
Expand Down
74 changes: 74 additions & 0 deletions test/compress/screw-ie8.js → test/compress/ie8.js
Expand Up @@ -464,3 +464,77 @@ issue_2976_2: {
}
expect_stdout: "PASS"
}

issue_3035: {
mangle = {
ie8: false,
}
input: {
var c = "FAIL";
(function(a) {
try {
throw 1;
} catch (b) {
try {
throw 0;
} catch (a) {
b && (c = "PASS");
}
}
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function(o) {
try {
throw 1;
} catch (t) {
try {
throw 0;
} catch (o) {
t && (c = "PASS");
}
}
})();
console.log(c);
}
expect_stdout: "PASS"
}

issue_3035_ie8: {
mangle = {
ie8: true,
}
input: {
var c = "FAIL";
(function(a) {
try {
throw 1;
} catch (b) {
try {
throw 0;
} catch (a) {
b && (c = "PASS");
}
}
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function(t) {
try {
throw 1;
} catch (o) {
try {
throw 0;
} catch (t) {
o && (c = "PASS");
}
}
})();
console.log(c);
}
expect_stdout: "PASS"
}

0 comments on commit fa32501

Please sign in to comment.