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
This commit is contained in:
Thakee Nathees 2022-04-25 16:53:07 +05:30
parent 95c318b6f7
commit cb209eb4d4
2 changed files with 9 additions and 2 deletions

View File

@ -2443,7 +2443,14 @@ static int compileClass(Compiler* compiler) {
checkMaxConstantsReached(compiler, cls_index); checkMaxConstantsReached(compiler, cls_index);
skipNewLines(compiler); 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 // 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. // a top level statement, since there aren't any locals at the top level.
ASSERT(compiler->parser.has_errors || ASSERT(compiler->parser.has_errors ||

View File

@ -664,7 +664,7 @@ static void _ctorNull(PKVM* vm) {
} }
static void _ctorBool(PKVM* vm) { static void _ctorBool(PKVM* vm) {
RET(toBool(ARG(1))); RET(VAR_BOOL(toBool(ARG(1))));
} }
static void _ctorNumber(PKVM* vm) { static void _ctorNumber(PKVM* vm) {