13
lib/scope.js
13
lib/scope.js
@@ -550,24 +550,23 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
|
|||||||
node.variables.each(collect);
|
node.variables.each(collect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (node.is_block_scope()) {
|
||||||
|
node.block_scope.variables.each(collect);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (node instanceof AST_Label) {
|
if (node instanceof AST_Label) {
|
||||||
var name;
|
var name;
|
||||||
do name = base54(++lname); while (!is_identifier(name));
|
do name = base54(++lname); while (!is_identifier(name));
|
||||||
node.mangled_name = name;
|
node.mangled_name = name;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var mangle_with_block_scope =
|
if (!options.ie8 && node instanceof AST_SymbolCatch) {
|
||||||
(!options.ie8 && node instanceof AST_SymbolCatch) ||
|
|
||||||
node instanceof AST_SymbolBlockDeclaration;
|
|
||||||
if (mangle_with_block_scope && options.reserved.indexOf(node.name) < 0) {
|
|
||||||
to_mangle.push(node.definition());
|
to_mangle.push(node.definition());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.walk(tw);
|
this.walk(tw);
|
||||||
to_mangle.forEach(function(def){
|
to_mangle.forEach(function(def){ def.mangle(options) });
|
||||||
def.mangle(options);
|
|
||||||
});
|
|
||||||
|
|
||||||
function collect(symbol) {
|
function collect(symbol) {
|
||||||
if (!member(symbol.name, options.reserved)) {
|
if (!member(symbol.name, options.reserved)) {
|
||||||
|
|||||||
@@ -1212,3 +1212,36 @@ issue_2676: {
|
|||||||
(class {}).a = 42;
|
(class {}).a = 42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2762: {
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var bar = 1, T = true;
|
||||||
|
(function() {
|
||||||
|
if (T) {
|
||||||
|
const a = function() {
|
||||||
|
var foo = bar;
|
||||||
|
console.log(foo, a.prop, b.prop);
|
||||||
|
};
|
||||||
|
a.prop = 2;
|
||||||
|
const b = { prop: 3 };
|
||||||
|
a();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var bar = 1, T = true;
|
||||||
|
(function() {
|
||||||
|
if (T) {
|
||||||
|
const o = function() {
|
||||||
|
var p = bar;
|
||||||
|
console.log(p, o.prop, r.prop);
|
||||||
|
};
|
||||||
|
o.prop = 2;
|
||||||
|
const r = { prop: 3 };
|
||||||
|
o();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "1 2 3"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user