diff options
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/scope.js b/lib/scope.js index ea35c0bf..f3010e7c 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -456,6 +456,7 @@ AST_Toplevel.DEFMETHOD("find_unique_prefix", function(options) { this.globals.each(add_def); this.walk(new TreeWalker(function(node) { if (node instanceof AST_Scope) node.variables.each(add_def); + if (node instanceof AST_SymbolCatch) add_def(node.definition()); })); var prefix, i = 0; do { @@ -492,17 +493,19 @@ AST_Toplevel.DEFMETHOD("expand_names", function(options) { this.globals.each(rename); this.walk(new TreeWalker(function(node) { if (node instanceof AST_Scope) node.variables.each(rename); + if (node instanceof AST_SymbolCatch) rename(node.definition()); })); function rename(def) { if (def.global || def.unmangleable(options)) return; if (member(def.name, options.reserved)) return; - var name = prefix + def.id; + var d = def.redefined(); + def.name = d ? d.name : prefix + def.id; def.orig.forEach(function(sym) { - sym.name = name; + sym.name = def.name; }); def.references.forEach(function(sym) { - sym.name = name; + sym.name = def.name; }); } }); |