From 984a21704e126616a74d65a1e8790aeccd02f548 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 28 Mar 2017 03:26:35 +0800 Subject: fix mangle for variable declared within catch block (#1706) fixes #1704 --- lib/scope.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3