1
0
Fork 0
forked from fun/fun

Fixed try/catch to run finally again. exit() in catch if you want to stop execution. (0.37.62)

This commit is contained in:
Johannes Findeisen 2026-01-24 21:17:40 +01:00
commit 869d68b992
4 changed files with 43 additions and 5 deletions

View file

@ -40,8 +40,8 @@ case OP_DIV: {
double da = (a.type == VAL_FLOAT) ? a.d : (double)a.i;
double db = (b.type == VAL_FLOAT) ? b.d : (double)b.i;
if (db == 0.0) {
fprintf(stderr, "Runtime error: division by zero\n");
exit(1);
vm_raise_error(vm, "division by zero");
break;
}
Value res = make_float(da / db);
free_value(a);
@ -49,8 +49,8 @@ case OP_DIV: {
push_value(vm, res);
} else {
if (b.i == 0) {
fprintf(stderr, "Runtime error: division by zero\n");
exit(1);
vm_raise_error(vm, "division by zero");
break;
}
Value res = make_int(a.i / b.i);
free_value(a);