Commit 898dcb3e

898dcb3e5f03Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

codegen: handle %= on a poly local via sp_poly_mod

The poly local op-assign arm mapped +,-,*,/ to sp_poly_ but not %, so x %= 0 on a widened local fell through to the unsupported path. Add the modulo case (sp_poly_mod, which raises ZeroDivisionError at runtime like the int path). Fixes integer_div_by_zero.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
898dcb3e5f03
Parent
dfa83a22bd62

src/codegen_stmt.cmodifiedView file

@@ -707,6 +707,7 @@
707707 else if (!strcmp(op, "-")) pfn = "sp_poly_sub";
708708 else if (!strcmp(op, "*")) pfn = "sp_poly_mul";
709709 else if (!strcmp(op, "/")) pfn = "sp_poly_div";
710+ else if (!strcmp(op, "%")) pfn = "sp_poly_mod";
710711 if (pfn) {
711712 buf_printf(b, "lv_%s = %s(lv_%s, ", en, pfn, en);
712713 emit_boxed(c, v, b);