Skip to content

Commit e4a8750

Browse files
committed
Avoid div by 0 in TypeInferenceMapper.map_floor_div
1 parent a52c0f0 commit e4a8750

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

loopy/type_inference.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ def _map_int_div_modulo(self, expr: p.FloorDiv | p.Remainder):
448448
if not is_integer(expr.denominator)
449449
else expr.denominator
450450
)
451+
denom = (
452+
denom + 1 if is_integer(denom) and denom == 0 else denom
453+
) # avoid divide by zero.
454+
451455
if is_integer(num) and is_integer(denom):
452456
return self.rec(num // denom)
453457

0 commit comments

Comments
 (0)