Commit 2d46808b
2d46808b2d42Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): case-as-expression form unboxes bigint scrutinee
compile_expr's CaseNode arm (the value-producing form, used when
case is on the rhs of an assignment) fell through to the generic
c_type(pred_type) <tmp> = <val>; branch for non-string/obj/poly
scrutinees. With promote mode widening an Integer scrutinee to
sp_Bigint *, the subsequent when-arm comparisons against int
literals (== 1LL, range endpoints, etc.) tripped pointer/int
comparisons.
Mirror the compile_case_stmt fix: add an explicit bigint arm that
unboxes to mrb_int via sp_bigint_to_int and rewrites pred_type
to "int" locally so the when-arm dispatch picks the int compare
path.
Promote-mode test count: 497 pass / 43 fail / 78 error -> 499 pass / 43 fail / 76 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 2d46808b2d42
- Parent
- 898cee72860c
spinel_codegen.rbmodifiedView file
# uses, but the scrutinee temp must follow pred_type. @needs_rb_value = 1 emit(" sp_RbVal " + ptmp + " = " + pred_val + ";") elsif pred_type == "bigint" # promote-mode-widened scrutinee: when-arms compare against # int literals / ranges, so unbox to mrb_int up front and # treat the temp as int for the when dispatch. @needs_bigint = 1 emit(" mrb_int " + ptmp + " = sp_bigint_to_int((sp_Bigint *)" + pred_val + ");") pred_type = "int" else emit(" " + c_type(pred_type) + " " + ptmp + " = " + pred_val + ";") end