From 2f1613e30693287e64479fd61aece67183d7a796 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 4 Feb 2023 03:03:56 +0000 Subject: [PATCH] Caught an error in the compiler --- source/toy_compiler.c | 2 +- test/scripts/ternary-expressions.toy | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/toy_compiler.c b/source/toy_compiler.c index cdec59b..848ce4f 100644 --- a/source/toy_compiler.c +++ b/source/toy_compiler.c @@ -365,7 +365,7 @@ static Toy_Opcode Toy_writeCompilerWithJumps(Toy_Compiler* compiler, Toy_ASTNode //write the else path Toy_Opcode override2 = Toy_writeCompilerWithJumps(compiler, node->pathIf.elsePath, breakAddressesPtr, continueAddressesPtr, jumpOffsets, rootNode); if (override2 != TOY_OP_EOF) {//compensate for indexing & dot notation being screwy - compiler->bytecode[compiler->count++] = (unsigned char)override; //1 byte + compiler->bytecode[compiler->count++] = (unsigned char)override2; //1 byte } //update the jumpToEnd to point here diff --git a/test/scripts/ternary-expressions.toy b/test/scripts/ternary-expressions.toy index 3d23509..be8fda6 100644 --- a/test/scripts/ternary-expressions.toy +++ b/test/scripts/ternary-expressions.toy @@ -18,7 +18,7 @@ //test division prevention { var x = 0; - assert (x ? 0 : 1 / x) == 0, "Division by zero prevention failed"; + assert x ? 0 : 1 / x == 0, "Division by zero prevention failed"; } //test ambiguous syntax @@ -29,7 +29,7 @@ var d = 4; var e = 5; - assert (a ? b ? c : d : e) == 3, "Ambiguous syntax failed"; + assert a ? b ? c : d : e == 3, "Ambiguous syntax failed"; }