raise a ZeroDivisionError when true-dividing by zero

This commit is contained in:
albertexye 2024-04-11 21:09:36 -04:00
parent 2129392b0e
commit 1b793fd5b2

View File

@ -372,6 +372,7 @@ void init_builtins(VM* _vm) {
});
_vm->bind__truediv__(VM::tp_int, [](VM* vm, PyObject* _0, PyObject* _1) {
f64 value = CAST_F(_1);
if (value == 0.) vm->ZeroDivisionError("division by zero");
return VAR(_CAST(i64, _0) / value);
});