Caught an error in the compiler

This commit is contained in:
2023-02-04 03:03:56 +00:00
parent 2776c87026
commit 2f1613e306
2 changed files with 3 additions and 3 deletions

View File

@@ -365,7 +365,7 @@ static Toy_Opcode Toy_writeCompilerWithJumps(Toy_Compiler* compiler, Toy_ASTNode
//write the else path //write the else path
Toy_Opcode override2 = Toy_writeCompilerWithJumps(compiler, node->pathIf.elsePath, breakAddressesPtr, continueAddressesPtr, jumpOffsets, rootNode); 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 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 //update the jumpToEnd to point here

View File

@@ -18,7 +18,7 @@
//test division prevention //test division prevention
{ {
var x = 0; 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 //test ambiguous syntax
@@ -29,7 +29,7 @@
var d = 4; var d = 4;
var e = 5; var e = 5;
assert (a ? b ? c : d : e) == 3, "Ambiguous syntax failed"; assert a ? b ? c : d : e == 3, "Ambiguous syntax failed";
} }