aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-01-04 01:03:33 +0800
committerGitHub <noreply@github.com>2018-01-04 01:03:33 +0800
commitcfe3a98ce50a1eb844654da57b4ef47a750feda5 (patch)
tree7c15b516108c4eda8a4e1836d059c7d54c8e9e15 /lib/scope.js
parent14778e049b12e131fc05ddacff9cda56dfede77d (diff)
downloadtracifyjs-cfe3a98ce50a1eb844654da57b4ef47a750feda5.tar.gz
tracifyjs-cfe3a98ce50a1eb844654da57b4ef47a750feda5.zip
drop `unused` assignment based on `reduce_vars` (#2709)
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js5
1 files changed, 4 insertions, 1 deletions
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);