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 === ilowered to(arg >= range.first && arg <= range.last)withargemitted raw. Whenargis a bigint local (promote-widened), the comparison against the mrb_int range endpoints failed -Wint-conversion. Route throughcompile_arg0_as_intwhich 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
# cover? for numeric ranges (Ruby docs: "tests for membership"). tmp = new_temp emit(" sp_Range " + tmp + " = " + rc + ";") arg = compile_arg0(nid) arg = compile_arg0_as_int(nid) return "(" + arg + " >= " + tmp + ".first && " + arg + " <= " + tmp + ".last)" end if mname == "to_a" emit(" mrb_bool " + tmp_res + " = " + init_val + ";") emit_iter_open(rc, recv_type, "lv_" + bp1, tmp_i) push_scope declare_var(bp1, iter_elem_type(recv_type)) bp1_t_pred = find_var_type(bp1) if bp1_t_pred != "bigint" bp1_t_pred = iter_elem_type(recv_type) end declare_var(bp1, bp1_t_pred) blk = @nd_block[nid] bbody = @nd_body[blk] bexpr = "0"