Commit 536eb53e

536eb53e5129Merged

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

Description

fix(codegen): int_array []= in expression context unboxes bigint idx/val

compile_int_array_method_expr's []= arm hoisted idx and value into mrb_int temps directly from compile_expr — a promote-widened bigint idx (e.g. from a method-returning-int call) flowed into mrb_int <tmp> = <sp_Bigint *> raw.

Snapshot each arg's inferred type and route through sp_bigint_to_int when bigint before the temp init.

Promote-mode test count: 530 pass / 50 fail / 38 error -> 531 pass / 50 fail / 37 error. Default raise mode unchanged at 618 / 0 / 0.

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

Details

Commit
536eb53e5129
Parent
6e8ec062f0d4

spinel_codegen.rbmodifiedView file

@@ -17807,14 +17807,29 @@
1780717807 # CRuby semantics. Issue #555 case 08.
1780817808 if a_set.length >= 3
1780917809 val_tmp = new_temp
17810- emit(" mrb_int " + val_tmp + " = " + compile_expr(a_set[a_set.length - 1]) + ";")
17810+ val_e_iae = compile_expr(a_set[a_set.length - 1])
17811+ if infer_type(a_set[a_set.length - 1]) == "bigint"
17812+ @needs_bigint = 1
17813+ val_e_iae = "sp_bigint_to_int((sp_Bigint *)" + val_e_iae + ")"
17814+ end
17815+ emit(" mrb_int " + val_tmp + " = " + val_e_iae + ";")
1781117816 return val_tmp
1781217817 end
1781317818 if a_set.length >= 2
1781417819 idx_tmp = new_temp
1781517820 val_tmp = new_temp
17816- emit(" mrb_int " + idx_tmp + " = " + compile_expr(a_set[0]) + ";")
17817- emit(" mrb_int " + val_tmp + " = " + compile_expr(a_set[1]) + ";")
17821+ idx_e_iae = compile_expr(a_set[0])
17822+ if infer_type(a_set[0]) == "bigint"
17823+ @needs_bigint = 1
17824+ idx_e_iae = "sp_bigint_to_int((sp_Bigint *)" + idx_e_iae + ")"
17825+ end
17826+ val_e_iae = compile_expr(a_set[1])
17827+ if infer_type(a_set[1]) == "bigint"
17828+ @needs_bigint = 1
17829+ val_e_iae = "sp_bigint_to_int((sp_Bigint *)" + val_e_iae + ")"
17830+ end
17831+ emit(" mrb_int " + idx_tmp + " = " + idx_e_iae + ";")
17832+ emit(" mrb_int " + val_tmp + " = " + val_e_iae + ";")
1781817833 emit(" sp_IntArray_set(" + rc + ", " + idx_tmp + ", " + val_tmp + ");")
1781917834 return val_tmp
1782017835 end