commit 5d3f81f553dc602164529513bf8b76831fbe3560
parent 9e9cced8180d445ccaa8fc9452f9f39f63688dda
Author: m21c <ho*******@gmail.com>
Date: Sat, 5 Feb 2022 13:18:56 +0100
fix: add function body of functions with no params to declaration
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/compiler.c b/compiler.c
@@ -2194,6 +2194,7 @@ redodeclaration:
decl = makedecl(source, key, DVAR);
decl->loc = loc;
decl->type = ty;
+
/* module for variable */
} else if (getkind(source) == TYPE) {
module = source->tok.type;
@@ -2275,6 +2276,10 @@ redodeclaration:
if (getkind(source) != OASS) {
body = stmtlist(source, source->lastindent,
SFUNCTION, decl, !!functionenv);
+
+ assert(body && body->kind == ASCOPE);
+ functionenv = body->u.env;
+
/* function init (body defined by assigment) */
} else if (getkind(source) == OASS) {
gettok(source);
@@ -2283,6 +2288,7 @@ redodeclaration:
body = readexpr(source, PASSIGN);
popenv(source);
+
/* no function body */
} else {
popenv(source);