fix mangle of block-scoped variables (#2779)

fixes #2762
This commit is contained in:
Alex Lam S.L
2018-01-14 12:12:29 +08:00
committed by GitHub
parent aa1786dedf
commit 8c763bf2b5
2 changed files with 39 additions and 7 deletions

View File

@@ -550,24 +550,23 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
node.variables.each(collect);
return;
}
if (node.is_block_scope()) {
node.block_scope.variables.each(collect);
return;
}
if (node instanceof AST_Label) {
var name;
do name = base54(++lname); while (!is_identifier(name));
node.mangled_name = name;
return true;
}
var mangle_with_block_scope =
(!options.ie8 && node instanceof AST_SymbolCatch) ||
node instanceof AST_SymbolBlockDeclaration;
if (mangle_with_block_scope && options.reserved.indexOf(node.name) < 0) {
if (!options.ie8 && node instanceof AST_SymbolCatch) {
to_mangle.push(node.definition());
return;
}
});
this.walk(tw);
to_mangle.forEach(function(def){
def.mangle(options);
});
to_mangle.forEach(function(def){ def.mangle(options) });
function collect(symbol) {
if (!member(symbol.name, options.reserved)) {