diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-31 02:57:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-31 02:57:47 +0800 |
commit | c595b84032b3083b87a976c8387010bf6074ad93 (patch) | |
tree | 7b4b6df422d94e852de672532d4ef9cb8acad8b6 /lib/scope.js | |
parent | 7cb1adf455f8ab440e1971ae41265c1f7f9a806a (diff) | |
download | tracifyjs-c595b84032b3083b87a976c8387010bf6074ad93.tar.gz tracifyjs-c595b84032b3083b87a976c8387010bf6074ad93.zip |
fix catch symbol mangling (#1734)
Only need to look up the immediate non-block/catch scope for the same-name special case.
fixes #1733
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/scope.js b/lib/scope.js index 025d4ca3..df0a7e00 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -79,9 +79,7 @@ SymbolDef.prototype = { if (!options.screw_ie8 && sym instanceof AST_SymbolLambda) s = s.parent_scope; var def; - if (options.screw_ie8 - && sym instanceof AST_SymbolCatch - && (def = s.parent_scope.find_variable(sym))) { + if (this.defun && (def = this.defun.variables.get(this.name))) { this.mangled_name = def.mangled_name || def.name; } else this.mangled_name = s.next_mangled(options, this); @@ -171,7 +169,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ } } else if (node instanceof AST_SymbolCatch) { - scope.def_variable(node); + scope.def_variable(node).defun = defun; } else if (node instanceof AST_LabelRef) { var sym = labels.get(node.name); @@ -227,7 +225,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ if (node instanceof AST_SymbolCatch) { var name = node.name; var refs = node.thedef.references; - var scope = node.thedef.scope.parent_scope; + var scope = node.thedef.defun; var def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node); refs.forEach(function(ref) { ref.thedef = def; |