Commit ed799891

ed79989191a8Merged

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

Description

fix(codegen): inlined yield assigns coerce when block param is bigint

compile_stmt_with_block's YieldNode arm emitted lv_<bp> = <yield_arg>; raw, and the padding pass for unset block params wrote lv_<bp> = 0;. With promote-mode-widened block param slots, a literal int yield arg or the "0" padding triggered -Wint-conversion against sp_Bigint *.

Probe the block param's outer-scope slot type via find_var_type and route int <-> bigint through sp_bigint_new_int / sp_bigint_to_int. The "0" pad uses sp_bigint_new_int(0) when the slot is bigint.

Promote-mode test count: 523 pass / 49 fail / 46 error -> 524 pass / 49 fail / 45 error. Default raise mode unchanged at 618 / 0 / 0.

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

Details

Commit
ed79989191a8
Parent
7f2aefd33142

spinel_codegen.rbmodifiedView file

@@ -34726,7 +34726,20 @@
3472634726 k = 0
3472734727 while k < aids.length
3472834728 if k < bp_names.length
34729- emit(" lv_" + bp_names[k] + " = " + compile_expr_remap(aids[k], map_from, map_to) + ";")
34729+ # Coerce when the block param's slot type differs from the
34730+ # yielded value's type (the canonical promote-mode shape
34731+ # `yield 1, 2` against bigint-widened block params).
34732+ bp_t_yarg = find_var_type(bp_names[k])
34733+ arg_v_yarg = compile_expr_remap(aids[k], map_from, map_to)
34734+ arg_t_yarg = infer_type(aids[k])
34735+ if bp_t_yarg == "bigint" && arg_t_yarg == "int"
34736+ @needs_bigint = 1
34737+ arg_v_yarg = "sp_bigint_new_int(" + arg_v_yarg + ")"
34738+ elsif bp_t_yarg == "int" && arg_t_yarg == "bigint"
34739+ @needs_bigint = 1
34740+ arg_v_yarg = "sp_bigint_to_int((sp_Bigint *)" + arg_v_yarg + ")"
34741+ end
34742+ emit(" lv_" + bp_names[k] + " = " + arg_v_yarg + ";")
3473034743 assigned = assigned + 1
3473134744 end
3473234745 k = k + 1
@@ -34737,7 +34750,13 @@
3473734750 # previous yield's values. Mirrors compile_yield_stmt's "0"
3473834751 # padding on the function-pointer dispatch path.
3473934752 while assigned < bp_names.length
34740- emit(" lv_" + bp_names[assigned] + " = 0;")
34753+ bp_reset_t = find_var_type(bp_names[assigned])
34754+ if bp_reset_t == "bigint"
34755+ @needs_bigint = 1
34756+ emit(" lv_" + bp_names[assigned] + " = sp_bigint_new_int(0);")
34757+ else
34758+ emit(" lv_" + bp_names[assigned] + " = 0;")
34759+ end
3474134760 assigned = assigned + 1
3474234761 end
3474334762 body = @nd_body[blk]