diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-28 03:26:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-28 03:26:35 +0800 |
commit | 984a21704e126616a74d65a1e8790aeccd02f548 (patch) | |
tree | 84fba1eb503c0ce076ca94165fddae12dd40ddbf /lib | |
parent | aa3f647656ce46469d20bd477b600ca09bc3f964 (diff) | |
download | tracifyjs-984a21704e126616a74d65a1e8790aeccd02f548.tar.gz tracifyjs-984a21704e126616a74d65a1e8790aeccd02f548.zip |
fix mangle for variable declared within catch block (#1706)
fixes #1704
Diffstat (limited to 'lib')
-rw-r--r-- | lib/scope.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/scope.js b/lib/scope.js index b255032c..c2d0b552 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -154,6 +154,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ else if (node instanceof AST_SymbolVar || node instanceof AST_SymbolConst) { defun.def_variable(node); + if (defun !== scope) node.mark_enclosed(options); } else if (node instanceof AST_SymbolCatch) { scope.def_variable(node); @@ -262,9 +263,8 @@ AST_Lambda.DEFMETHOD("init_scope_vars", function(){ })); }); -AST_SymbolRef.DEFMETHOD("reference", function(options) { +AST_Symbol.DEFMETHOD("mark_enclosed", function(options) { var def = this.definition(); - def.references.push(this); var s = this.scope; while (s) { push_uniq(s.enclosed, def); @@ -278,6 +278,11 @@ AST_SymbolRef.DEFMETHOD("reference", function(options) { } }); +AST_SymbolRef.DEFMETHOD("reference", function(options) { + this.definition().references.push(this); + this.mark_enclosed(options); +}); + AST_Scope.DEFMETHOD("find_variable", function(name){ if (name instanceof AST_Symbol) name = name.name; return this.variables.get(name) |