From cfe3a98ce50a1eb844654da57b4ef47a750feda5 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 4 Jan 2018 01:03:33 +0800 Subject: drop `unused` assignment based on `reduce_vars` (#2709) --- lib/scope.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/scope.js') diff --git a/lib/scope.js b/lib/scope.js index 79b2475d..de92fc94 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -151,7 +151,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ node.references = []; } if (node instanceof AST_SymbolLambda) { - defun.def_function(node); + defun.def_function(node, defun); } else if (node instanceof AST_SymbolDefun) { // Careful here, the scope where this should be defined is @@ -318,6 +318,9 @@ AST_Scope.DEFMETHOD("def_variable", function(symbol, init){ var def = this.variables.get(symbol.name); if (def) { def.orig.push(symbol); + if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) { + def.init = init; + } } else { def = new SymbolDef(this, symbol, init); this.variables.set(symbol.name, def); -- cgit v1.2.3