Commit 6ab20447

6ab20447be4fMerged

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

Description

fix(codegen): cmeth kwarg call site coerces positional int args to bigint

compile_constant_recv_expr's class-method-with-kwargs path compiled each positional argument via raw compile_expr + cast_away_volatile_arg, dropping the int->bigint cast that compile_typed_call_args already applies for ordinary call sites. A W.write(200, set_cookies: cookies) call against a promote-mode- widened def self.write(status, set_cookies: {}) then emitted sp_W_cls_write(200LL, lv_cookies) with the first arg as mrb_int against a sp_Bigint * param.

Route the positional slot through compile_expr_for_expected_type when the parameter's declared base type is bigint or int, so the helper's existing int<->bigint coerce arm fires.

Promote-mode test count: 460 pass / 44 fail / 114 error -> 466 pass / 46 fail / 106 error. Default raise mode unchanged at 618 / 0 / 0.

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

Details

Commit
6ab20447be4f
Parent
2270a7d25500

spinel_codegen.rbmodifiedView file

@@ -19641,7 +19641,16 @@
1964119641 while kk < owner_pn.length
1964219642 slot_expr_cm = ""
1964319643 if pos_idx_cm < positional_cm.length
19644- slot_expr_cm = cast_away_volatile_arg(positional_cm[pos_idx_cm], compile_expr(positional_cm[pos_idx_cm]))
19644+ # Route through compile_expr_for_expected_type when the
19645+ # slot's declared type needs an int<->bigint cast (promote
19646+ # mode often promotes the param while the call site still
19647+ # passes a literal int / int-typed local).
19648+ slot_pt_pos_cm = kk < owner_pt.length ? owner_pt[kk] : ""
19649+ if slot_pt_pos_cm != "" && (base_type(slot_pt_pos_cm) == "bigint" || base_type(slot_pt_pos_cm) == "int")
19650+ slot_expr_cm = compile_expr_for_expected_type(positional_cm[pos_idx_cm], slot_pt_pos_cm)
19651+ else
19652+ slot_expr_cm = cast_away_volatile_arg(positional_cm[pos_idx_cm], compile_expr(positional_cm[pos_idx_cm]))
19653+ end
1964519654 pos_idx_cm = pos_idx_cm + 1
1964619655 else
1964719656 # Try kwarg by name.