Found a weird bug, reporting it

This commit is contained in:
2022-08-20 13:44:55 +01:00
parent f5e060051e
commit daceaa5492
4 changed files with 16 additions and 9 deletions

View File

@@ -3,17 +3,16 @@ DONE: var decl with a type, but no value
DONE: type casting
DONE: remove optimization option
DONE: conditionals
DONE: if-then-else
DONE: chained if-then-else
DONE: optional block around a path if it's only one statement
DONE: while-then
DONE: for-then
TODO: string concat with the + operator
TODO: empty string as falsy?
TODO: increment & decrement operators
TODO: a = b = c = 1;
TODO: are compounds shallow or deep copies?
TODO: if-then-else
TODO: chained if-then-else
TODO: optional block around a path if it's only one statement
TODO: while-then
TODO: for-then
TODO: break and continue statements
TODO: functions, and all of their features
TODO: Assertion-based test scripts

9
scripts/empty.toy Normal file
View File

@@ -0,0 +1,9 @@
//BUG: this causes a strange error message
if (true) {
;
}
else {
;
}

View File

@@ -573,7 +573,7 @@ static bool execCompareLessEqual(Interpreter* interpreter, bool invert) {
static bool execJump(Interpreter* interpreter) {
int target = (int)readShort(interpreter->bytecode, &interpreter->count);
if (target >= interpreter->length) {
if (target + interpreter->codeStart > interpreter->length) {
printf("Jump out of range\n");
return false;
}
@@ -587,7 +587,7 @@ static bool execJump(Interpreter* interpreter) {
static bool execFalseJump(Interpreter* interpreter) {
int target = (int)readShort(interpreter->bytecode, &interpreter->count);
if (target >= interpreter->length) {
if (target + interpreter->codeStart > interpreter->length) {
printf("Jump out of range\n");
return false;
}

View File

@@ -37,4 +37,3 @@ assert forCache == 19, "for-loop failed";
print "All good";