From cb209eb4d471079d9c4e7ef432dbd2dcfc878fc3 Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Mon, 25 Apr 2022 16:53:07 +0530 Subject: [PATCH] Some tiny bugs bug fix When parsing class and if there is an EOF it's not being marked as an error which is a regression after the syntax error refactor which is fixed. Constructor of boolean class return C boolean instead of VAR_BOOL() bug fixed --- src/pk_compiler.c | 9 ++++++++- src/pk_core.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pk_compiler.c b/src/pk_compiler.c index 11c830d..e6dff49 100644 --- a/src/pk_compiler.c +++ b/src/pk_compiler.c @@ -2443,7 +2443,14 @@ static int compileClass(Compiler* compiler) { checkMaxConstantsReached(compiler, cls_index); skipNewLines(compiler); - while (!match(compiler, TK_END) && !match(compiler, TK_EOF)) { + while (!match(compiler, TK_END)) { + + if (match(compiler, TK_EOF)) { + syntaxError(compiler, compiler->parser.previous, + "Unexpected EOF while parsing class."); + break; + } + // At the top level the stack size should be 0, before and after compiling // a top level statement, since there aren't any locals at the top level. ASSERT(compiler->parser.has_errors || diff --git a/src/pk_core.c b/src/pk_core.c index 5f2f6bb..f3c2b80 100644 --- a/src/pk_core.c +++ b/src/pk_core.c @@ -664,7 +664,7 @@ static void _ctorNull(PKVM* vm) { } static void _ctorBool(PKVM* vm) { - RET(toBool(ARG(1))); + RET(VAR_BOOL(toBool(ARG(1)))); } static void _ctorNumber(PKVM* vm) {