Commit 76c4c2c1
76c4c2c1e64fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): sized-array helper count expr unboxes bigint
compile_expr_for_expected_type and compile_stmt's sized-empty-
array shapes (Array.new(N) { ... } / [nil] * N) used
compile_arg0(nid) to fetch the count, which left a promote-
widened bigint count expression unwrapped before
mrb_int _n = <expr>; initialization.
Route through compile_arg0_as_int so the int / bigint unbox
arm fires.
Promote-mode test count: 508 pass / 44 fail / 66 error -> 508 pass / 45 fail / 65 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 76c4c2c1e64f
- Parent
- 5430941173f9
spinel_codegen.rbmodifiedView file
@@ -5499,7 +5499,7 @@
54995499
# which doesn't match the LHS storage.55005500
if (is_ptr_array_type(expected_base) == 1 || expected_base == "poly_array") && is_sized_empty_array_default(nid) == 155015501
@needs_gc = 15502-
cnt_e = compile_arg0(nid)5502+
cnt_e = compile_arg0_as_int(nid)55035503
tmp = new_temp55045504
if expected_base == "poly_array"55055505
@needs_rb_value = 1@@ -5521,7 +5521,7 @@
55215521
if expected_base == "poly" && is_sized_empty_array_default(nid) == 155225522
@needs_gc = 155235523
@needs_rb_value = 15524-
cnt_e = compile_arg0(nid)5524+
cnt_e = compile_arg0_as_int(nid)55255525
tmp = new_temp55265526
emit(" sp_PolyArray *" + tmp + " = sp_PolyArray_new();")55275527
emit(" { mrb_int _n = " + cnt_e + "; for (mrb_int _i = 0; _i < _n; _i++) sp_PolyArray_push(" + tmp + ", sp_box_nil()); }")@@ -25301,7 +25301,7 @@
2530125301
# holds the matching storage.2530225302
if (ivt == "poly_array" || is_ptr_array_type(ivt) == 1) && is_sized_empty_array_default(expr_id) == 12530325303
@needs_gc = 125304-
cnt_e = compile_arg0(expr_id)25304+
cnt_e = compile_arg0_as_int(expr_id)2530525305
tmp_arr = new_temp2530625306
if ivt == "poly_array"2530725307
@needs_rb_value = 1@@ -25323,7 +25323,7 @@
2532325323
if ivt == "poly" && is_sized_empty_array_default(expr_id) == 12532425324
@needs_gc = 12532525325
@needs_rb_value = 125326-
cnt_e = compile_arg0(expr_id)25326+
cnt_e = compile_arg0_as_int(expr_id)2532725327
tmp_arr = new_temp2532825328
emit(" sp_PolyArray *" + tmp_arr + " = sp_PolyArray_new();")2532925329
emit(" { mrb_int _n = " + cnt_e + "; for (mrb_int _i = 0; _i < _n; _i++) sp_PolyArray_push(" + tmp_arr + ", sp_box_nil()); }")