Commit 312589b2

312589b2180bMerged

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

Description

fix(codegen): super(...) call boxes int->bigint at parent param boundary

super(0) against a parent initialize(kind) whose kind slot promoted to bigint cast the int literal directly to a pointer ((sp_Bigint *)0LL) -- NULL. sp_bigint_cmp then null-derefed.

Use sp_bigint_new_int / sp_bigint_to_int at the boundary like the rest of the int<->bigint coerce paths. Picks up gc_scan_skip_inherited_ivar.

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

Details

Commit
312589b2180b
Parent
47f481b46f5e

spinel_codegen.rbmodifiedView file

@@ -9837,7 +9837,20 @@
98379837 if ak < p_ptypes.length
98389838 at_arg = infer_type(arg_ids[ak])
98399839 if p_ptypes[ak] != at_arg && p_ptypes[ak] != ""
9840- arg_expr2 = "(" + c_type(p_ptypes[ak]) + ")" + arg_expr2
9840+ # int -> bigint: box via sp_bigint_new_int. A raw cast would
9841+ # produce a NULL pointer for literal 0 / negative ints and
9842+ # garbage for nonzero literals (interprets the int as a heap
9843+ # address). Same shape on the inverse path: bigint -> int
9844+ # unbox via sp_bigint_to_int.
9845+ if base_type(p_ptypes[ak]) == "bigint" && base_type(at_arg) == "int"
9846+ @needs_bigint = 1
9847+ arg_expr2 = "sp_bigint_new_int(" + arg_expr2 + ")"
9848+ elsif base_type(p_ptypes[ak]) == "int" && base_type(at_arg) == "bigint"
9849+ @needs_bigint = 1
9850+ arg_expr2 = "sp_bigint_to_int((sp_Bigint *)" + arg_expr2 + ")"
9851+ else
9852+ arg_expr2 = "(" + c_type(p_ptypes[ak]) + ")" + arg_expr2
9853+ end
98419854 end
98429855 end
98439856 super_args = super_args + arg_expr2