Commit 7e132dff
7e132dff9f8cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): splat call args coerce int<->bigint at param boundary
compile_call_args_splat had two spots that didn't coerce:
- splat-source element (
sp_IntArray_get) into a bigint-promoted fixed param. - prefix positional (
mix(1, 2, *xs)literals before the splat) into a bigint param — was compile_expr raw.
Route splat elements through sp_bigint_new_int / sp_bigint_to_int on type mismatch; route prefix positionals through compile_expr _for_expected_type so the helper's coerce fires.
Promote-mode test count: 537 pass / 54 fail / 27 error -> 538 pass / 54 fail / 26 error. Default raise mode 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 7e132dff9f8c
- Parent
- fa08c47c15e5
spinel_codegen.rbmodifiedView file
@@ -23300,7 +23300,9 @@
2330023300
if coerced != ""2330123301
result = result + coerced2330223302
else23303-
result = result + compile_expr(positional_ids[k])23303+
# Route through compile_expr_for_expected_type so int<->23304+
# bigint coerce fires for promote-mode-widened params.23305+
result = result + compile_expr_for_expected_type(positional_ids[k], pt)2330423306
end2330523307
end2330623308
k = k + 1@@ -23317,9 +23319,19 @@
2331723319
slots_left_for_splat = n_fixed - prefix_count2331823320
if idx_in_splat < slots_left_for_splat2331923321
ge = array_get_native_expr(src_t, src_v, idx_in_splat.to_s)23322+
# Coerce when the splat source's elem type doesn't match the23323+
# callee's param slot — promote-mode IntArray element (mrb_int)23324+
# into a bigint-promoted param.23325+
elem_t_spl = elem_type_of_array(src_t)2332023326
if pt == "poly"2332123327
# The splat element itself isn't a node id, so wrap manually.2332223328
result = result + ge23329+
elsif base_type(pt) == "bigint" && elem_t_spl == "int"23330+
@needs_bigint = 123331+
result = result + "sp_bigint_new_int(" + ge + ")"23332+
elsif base_type(pt) == "int" && elem_t_spl == "bigint"23333+
@needs_bigint = 123334+
result = result + "sp_bigint_to_int((sp_Bigint *)" + ge + ")"2332323335
else2332423336
result = result + ge2332523337
end