From fdf5bdc2672db3b082e3b850dda5169b8c5620b5 Mon Sep 17 00:00:00 2001 From: Francesco Cozzuto Date: Fri, 15 Apr 2022 19:17:42 +0200 Subject: [PATCH] bug fix --- src/compiler/compile.c | 7 +++++++ src/runtime/runtime.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile.c b/src/compiler/compile.c index 6151cb2..83f2d80 100644 --- a/src/compiler/compile.c +++ b/src/compiler/compile.c @@ -679,6 +679,13 @@ static _Bool emit_instr_for_node(ExeBuilder *exeb, Node *node, Promise *break_de if(!emit_instr_for_node(exeb, func->body, NULL, error)) return 0; + if(func->body->kind == NODE_EXPR) + { + Operand op = (Operand) { .type = OPTP_INT, .as_int = 1 }; + if(!ExeBuilder_Append(exeb, error, OPCODE_POP, &op, 1, func->body->offset + func->body->length, 0)) + return 0; + } + // Write a return instruction, just // in case it didn't already return. Operand op = (Operand) { .type = OPTP_INT, .as_int = 0 }; diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index f4c4aab..bf4e6be 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1185,7 +1185,7 @@ static _Bool step(Runtime *runtime, Error *error) if(!Object_IsBool(top)) { - Error_Report(error, 1, "JUMPIFNOTANDPOP expected a boolean on the stack"); + Error_Report(error, 0, "Not a boolean"); return 0; } @@ -1217,7 +1217,7 @@ static _Bool step(Runtime *runtime, Error *error) if(!Object_IsBool(top)) { - Error_Report(error, 1, "JUMPIFNOTANDPOP expected a boolean on the stack"); + Error_Report(error, 0, "Not a boolean"); return 0; }