fix corner case in evaluate (#4341)

fixes #4340
This commit is contained in:
Alex Lam S.L
2020-12-07 08:05:11 +00:00
committed by GitHub
parent 2f31f95095
commit fbecedf94c
4 changed files with 32 additions and 11 deletions

View File

@@ -112,7 +112,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
var next_def_id = 0;
var scope = self.parent_scope = null;
var tw = new TreeWalker(function(node, descend) {
if (node instanceof AST_AsyncDefun || node instanceof AST_Defun) {
if (is_defun(node)) {
node.name.walk(tw);
walk_scope(function() {
node.argnames.forEach(function(argname) {
@@ -397,7 +397,7 @@ AST_BlockScope.DEFMETHOD("find_variable", function(name) {
AST_BlockScope.DEFMETHOD("def_function", function(symbol, init) {
var def = this.def_variable(symbol, init);
if (!def.init || def.init instanceof AST_Defun) def.init = init;
if (!def.init || is_defun(def.init)) def.init = init;
this.functions.set(symbol.name, def);
return def;
});
@@ -406,7 +406,7 @@ AST_BlockScope.DEFMETHOD("def_variable", function(symbol, init) {
var def = this.variables.get(symbol.name);
if (def) {
def.orig.push(symbol);
if (def.init instanceof AST_Function) def.init = init;
if (is_function(def.init)) def.init = init;
} else {
def = this.make_def(symbol, init);
this.variables.set(symbol.name, def);