Commit b9c8e85c
b9c8e85c4745Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): kwarg arg coerces int<->bigint to declared param type
compile_call_args_with_defaults matched kwargs to params by name
and emitted the raw kw_vals[ki] against the declared slot type
(except for the poly arm). With promote mode widening a numeric
kwarg's param to bigint (def truncate(s, length, suffix); end
called as M.truncate(s, length: 100)), the int literal flowed
into a sp_Bigint * slot unwrapped.
Coerce via sp_bigint_new_int / sp_bigint_to_int when the inferred kw arg type and the declared param type disagree across the int <-> bigint boundary.
Promote-mode test count: 529 pass / 50 fail / 39 error -> 530 pass / 50 fail / 38 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- b9c8e85c4745
- Parent
- 2bcdb4b43e01
spinel_codegen.rbmodifiedView file
# that flows non-string objs through here. result = result + box_expr_to_poly(kw_arg_ids[ki]) else result = result + kw_vals[ki] # promote-mode coerce: kw value's static type vs # param's declared type may need int <-> bigint. kw_val_pft = kw_vals[ki] kw_arg_t_pft = ki < kw_arg_ids.length ? infer_type(kw_arg_ids[ki]) : "" if base_type(ptypes[k]) == "bigint" && kw_arg_t_pft == "int" @needs_bigint = 1 kw_val_pft = "sp_bigint_new_int(" + kw_val_pft + ")" elsif base_type(ptypes[k]) == "int" && kw_arg_t_pft == "bigint" @needs_bigint = 1 kw_val_pft = "sp_bigint_to_int((sp_Bigint *)" + kw_val_pft + ")" end result = result + kw_val_pft end else result = result + kw_vals[ki]