basic: on DEFUN, unknown variables will be regarded as a global

This commit is contained in:
minjaesong
2020-12-09 09:40:16 +09:00
parent 9fa9a0a203
commit 1177690ee3
3 changed files with 11 additions and 5 deletions

View File

@@ -1995,12 +1995,11 @@ bF._executeSyntaxTree = function(lnum, syntaxTree, recDepth) {
bF._recurseApplyAST(exprTree, (it) => {
if (it.astType == "lit") {
// check if parametre name is valid
if (defunRenamingMap[it.astValue] === undefined) {
throw lang.refError(lnum, it.astValue);
// if the name is invalid, regard it as a global variable (i.e. do nothing)
if (defunRenamingMap[it.astValue] !== undefined) {
it.astType = "defun_args";
it.astValue = defunRenamingMap[it.astValue];
}
it.astType = "defun_args";
it.astValue = defunRenamingMap[it.astValue];
}
// decrease the recursion counter while we're looping
it.astDepth -= 2;