fix: treat `bool`s as `int`s in arithmetic expressions.
Merged
JA
2mo ago+487+487+012345678901234567890123456789-69-69-01234567890123456789
Fixes: #963
Treat boolean operands as integers when doing arithmetic calculations (addition, subtraction, etc).
Using immediate_int and immediate_float helper for basic arithmetic.
Using py_float_divmod for correct // behaviour.
Simplifying pow when the base value is a boolean.
Summary by cubic
Makes arithmetic operations treat bool operands as integers (True = 1, False = 0), fixing #963.
+,-, and%now acceptbool/int/floatcombinations and return the same types as CPython.//usespy_float_divmodso float floor division matchesdivmodsemantics, including special values like infinity and NaN.bool ** intwith a nonnegative exponent simplifies to0or1without overflow, matching CPython.- Adds a test file covering bool operands across arithmetic, overflow boundaries, augmented assignment, and truthiness in
sum()patterns.