Commit c2d339e3

c2d339e3d1efMerged

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

Description

fix(codegen): poly dispatch arm treats int/bigint as compatible in promote mode

poly_dispatch_arm_param_compat and the inline arm_incompat check in compile_poly_method_call rejected user-class arms whose param was bigint when the dispatch site supplied an int (literal or int- typed LV). Under SPINEL_INT_OVERFLOW=promote the two types are numerically interchangeable -- the call boundary just needs an sp_bigint_new_int / sp_bigint_to_int bridge -- so suppressing the arm dropped the user-class branch entirely and the dispatch fell to its nil-default.

Emit the bridge expressions per-arm when arm param is bigint and arg is int (or vice versa). Also classify (int, bigint) as compatible in poly_dispatch_arm_param_compat so the return-type union sees the bigint return from the otherwise-suppressed arm.

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

Details

Commit
c2d339e3d1ef
Parent
1c351765afb5

compiler_helpers.rbmodifiedView file

@@ -389,6 +389,9 @@
389389 if (at_b == "int" && pt_b == "symbol") || (at_b == "symbol" && pt_b == "int") ||
390390 (at_b == "int" && pt_b == "bool") || (at_b == "bool" && pt_b == "int")
391391 # compatible
392+ elsif (at_b == "int" && pt_b == "bigint") || (at_b == "bigint" && pt_b == "int")
393+ # promote mode: int and bigint coerce at the call boundary via
394+ # sp_bigint_new_int / sp_bigint_to_int.
392395 else
393396 return 0
394397 end