Commit 0f5caa5b

0f5caa5b04deMerged

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

Description

fix(codegen): Range#include?/cover? / Array#predicate? bigint-aware args

Two related bigint coercions:

  • range.cover?(i) / range.include?(i) / range === i lowered to (arg >= range.first && arg <= range.last) with arg emitted raw. When arg is a bigint local (promote-widened), the comparison against the mrb_int range endpoints failed -Wint-conversion. Route through compile_arg0_as_int which already unboxes via sp_bigint_to_int.

  • compile_array_predicate_block (all? / any? / none? / one?) declared the block param at the iterator's element type, losing the outer-scope bigint widening — block-body comparisons against int literals then dispatched as raw int. Probe find_var_type for the outer slot and prefer bigint when found.

Promote-mode test count: 503 pass / 43 fail / 72 error -> 504 pass / 43 fail / 71 error. Default raise mode unchanged at 618 / 0 / 0.

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

Details

Commit
0f5caa5b04de
Parent
a10021ea03fe

spinel_codegen.rbmodifiedView file

@@ -16628,7 +16628,7 @@
1662816628 # cover? for numeric ranges (Ruby docs: "tests for membership").
1662916629 tmp = new_temp
1663016630 emit(" sp_Range " + tmp + " = " + rc + ";")
16631- arg = compile_arg0(nid)
16631+ arg = compile_arg0_as_int(nid)
1663216632 return "(" + arg + " >= " + tmp + ".first && " + arg + " <= " + tmp + ".last)"
1663316633 end
1663416634 if mname == "to_a"
@@ -32420,7 +32420,11 @@
3242032420 emit(" mrb_bool " + tmp_res + " = " + init_val + ";")
3242132421 emit_iter_open(rc, recv_type, "lv_" + bp1, tmp_i)
3242232422 push_scope
32423- declare_var(bp1, iter_elem_type(recv_type))
32423+ bp1_t_pred = find_var_type(bp1)
32424+ if bp1_t_pred != "bigint"
32425+ bp1_t_pred = iter_elem_type(recv_type)
32426+ end
32427+ declare_var(bp1, bp1_t_pred)
3242432428 blk = @nd_block[nid]
3242532429 bbody = @nd_body[blk]
3242632430 bexpr = "0"