Commit dea3ce87
dea3ce875d95Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): case-expr scrutinee unboxes bigint to mrb_int before when-cmp
compile_case_stmt and compile_case_return fell through to a
generic mrb_int <tmp> = <pred_val>; for non-string/obj/poly/
range/float/bool predicates. With promote mode widening an Integer
predicate to sp_Bigint *, the assignment then failed
-Wint-conversion.
Add an explicit bigint arm that unboxes via sp_bigint_to_int
before the when-arm comparisons (which are still int-shaped:
literal value or Range integer endpoints). Sets pred_type back to
"int" locally so compile_when_conds picks the int-cmp path.
Promote-mode test count: 467 pass / 46 fail / 105 error -> 470 pass / 46 fail / 102 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- dea3ce875d95
- Parent
- 54c24da867ae
spinel_codegen.rbmodifiedView file
# struct value to an int, tripping the C compiler. Issue #604 # sibling: a case as a function tail with a Range scrutinee. emit(" " + c_type(pred_type) + " " + tmp + " = " + pred_val + ";") elsif pred_type == "bigint" # promote-mode-widened predicate: keep the temp typed as # bigint and unbox to mrb_int for the when comparisons via # the compile_when_conds path (which already handles the # bigint cmp through sp_bigint_to_int when needed). @needs_bigint = 1 emit(" mrb_int " + tmp + " = sp_bigint_to_int((sp_Bigint *)" + pred_val + ");") pred_type = "int" else emit(" mrb_int " + tmp + " = " + pred_val + ";") end bt_cr = base_type(pred_type) cn_cr = bt_cr[4, bt_cr.length - 4] emit(" sp_" + cn_cr + " *" + tmp + " = " + pred_val + ";") elsif pred_type == "bigint" @needs_bigint = 1 emit(" mrb_int " + tmp + " = sp_bigint_to_int((sp_Bigint *)" + pred_val + ");") pred_type = "int" else emit(" mrb_int " + tmp + " = " + pred_val + ";") end