commit 31d34ed7313e65e5f445ee38a9d96a498efc5950
parent d9755153f789f89bbe8f49183565ed14961affa2
Author: m21c <ho*******@gmail.com>
Date: Sun, 3 Oct 2021 19:55:12 +0200
fixed error-reporting for undeclared symbols
Diffstat:
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/compiler.c b/compiler.c
@@ -1628,7 +1628,7 @@ popenv(Source *source)
return env;
}
-static void
+static bool
deferfuncenv(Source *source, int keydeclinfunc)
{
Env *env, *funcenv = NULL;
@@ -1661,7 +1661,11 @@ deferfuncenv(Source *source, int keydeclinfunc)
"'%s' undeclared",
getstring(idents, keydeclinfunc)
);
+
+ return false;
}
+
+ return true;
}
@@ -2261,10 +2265,15 @@ readident(Source *source, int flags)
lhs->type = decl->type;
lhs->u.declref = decl;
} else {
- deferfuncenv(source, key);
- lhs->kind = 'I';
+ if (deferfuncenv(source, key)) {
+ lhs->kind = 'I';
+ lhs->u.key = key;
+ } else {
+ lhs->kind = 'N';
+ lhs->u.u = 0;
+ }
+
lhs->type = prim + TVOID;
- lhs->u.key = key;
}
if (flags & QCONST) {