Commit 6594360f

6594360f1b95Merged

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

Description

fix(codegen): box_value_to_poly handles bigint via sp_bigint_to_int + sp_box_int

box_value_to_poly had no bigint arm — promote-mode block tails flowing into a PolyArray push ((0...3).map { i * 10 } widened by a heterogeneous outer collector) sent the sp_Bigint * straight to sp_box_int, which expects mrb_int. Big regression target: 8 tests flipped from fail to pass.

Unbox via sp_bigint_to_int and route through sp_box_int. The value-fits assumption matches every other bigint -> mrb_int coerce in this codebase; if the value doesn't fit, the truncation is the same semantic as any other narrowing path here.

Promote-mode test count: 538 pass / 55 fail / 25 error -> 546 pass / 47 fail / 25 error. Default raise mode 618 / 0 / 0.

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

Details

Commit
6594360f1b95
Parent
593a14b45ca0

spinel_codegen.rbmodifiedView file

@@ -22769,6 +22769,16 @@
2276922769 if at == "int"
2277022770 return "sp_box_int(" + val + ")"
2277122771 end
22772+ if at == "bigint"
22773+ # No dedicated SP_BUILTIN_BIGINT slot in the box helpers; unbox
22774+ # to mrb_int and route through sp_box_int. The value fits when
22775+ # it does (the canonical promote-mode scenario where the bigint
22776+ # is just an int-sized integer wearing the bigint suit); larger
22777+ # values truncate, which is the same trade-off as any other
22778+ # bigint -> mrb_int coerce in this codegen.
22779+ @needs_bigint = 1
22780+ return "sp_box_int(sp_bigint_to_int((sp_Bigint *)" + val + "))"
22781+ end
2277222782 if at == "string"
2277322783 return "sp_box_str(" + val + ")"
2277422784 end