Commit 12843766
128437662376Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): include? dispatch arm accepts bigint arg in promote mode
The int-arg branch of the include? poly_builtin dispatch picks up
SP_BUILTIN_INT_ARRAY / SP_BUILTIN_INT_STR_HASH / SP_BUILTIN_RANGE.
The branch gated on inc_arg_t == "int" which left out promote-mode
bigint args, so a Range narrowed via case/when fell through to the
0 default (always-false). Accept base_type == "bigint" too, unboxing
via sp_bigint_to_int before passing the value to the mrb_int-taking
helpers (sp_IntArray_include / sp_range_include).
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 128437662376
- Parent
- fd72fbcf3842
spinel_codegen.rbmodifiedView file
@@ -22928,14 +22928,19 @@
2292822928
# `case x; when Range; r.include?(actual)` against a poly2292922929
# receiver lands on the right path instead of falling through2293022930
# to "0" (always-false).22931-
if inc_arg_t == "int"22932-
iac = "sp_IntArray_include((sp_IntArray *)" + recv_tmp + ".v.p, " + inc_arg + ")"22931+
if inc_arg_t == "int" || base_type(inc_arg_t) == "bigint"22932+
inc_arg_i = inc_arg22933+
if base_type(inc_arg_t) == "bigint"22934+
@needs_bigint = 122935+
inc_arg_i = "sp_bigint_to_int((sp_Bigint *)" + inc_arg + ")"22936+
end22937+
iac = "sp_IntArray_include((sp_IntArray *)" + recv_tmp + ".v.p, " + inc_arg_i + ")"2293322938
iarhs = is_poly_ret == 1 ? "sp_box_bool(" + iac + ")" : iac2293422939
emit(" if (" + recv_tmp + ".cls_id == SP_BUILTIN_INT_ARRAY) " + result_tmp + " = " + iarhs + ";")22935-
ishc = "sp_IntStrHash_has_key((sp_IntStrHash *)" + recv_tmp + ".v.p, " + inc_arg + ")"22940+
ishc = "sp_IntStrHash_has_key((sp_IntStrHash *)" + recv_tmp + ".v.p, " + inc_arg_i + ")"2293622941
ishrhs = is_poly_ret == 1 ? "sp_box_bool(" + ishc + ")" : ishc2293722942
emit(" if (" + recv_tmp + ".cls_id == SP_BUILTIN_INT_STR_HASH) " + result_tmp + " = " + ishrhs + ";")22938-
rgc = "sp_range_include((sp_Range *)" + recv_tmp + ".v.p, " + inc_arg + ")"22943+
rgc = "sp_range_include((sp_Range *)" + recv_tmp + ".v.p, " + inc_arg_i + ")"2293922944
rgrhs = is_poly_ret == 1 ? "sp_box_bool(" + rgc + ")" : rgc2294022945
emit(" if (" + recv_tmp + ".cls_id == SP_BUILTIN_RANGE) " + result_tmp + " = " + rgrhs + ";")2294122946
end