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
k = 0 while k < aids.length if k < bp_names.length emit(" lv_" + bp_names[k] + " = " + compile_expr_remap(aids[k], map_from, map_to) + ";") # Coerce when the block param's slot type differs from the # yielded value's type (the canonical promote-mode shape # `yield 1, 2` against bigint-widened block params). bp_t_yarg = find_var_type(bp_names[k]) arg_v_yarg = compile_expr_remap(aids[k], map_from, map_to) arg_t_yarg = infer_type(aids[k]) if bp_t_yarg == "bigint" && arg_t_yarg == "int" @needs_bigint = 1 arg_v_yarg = "sp_bigint_new_int(" + arg_v_yarg + ")" elsif bp_t_yarg == "int" && arg_t_yarg == "bigint" @needs_bigint = 1 arg_v_yarg = "sp_bigint_to_int((sp_Bigint *)" + arg_v_yarg + ")" end emit(" lv_" + bp_names[k] + " = " + arg_v_yarg + ";") assigned = assigned + 1 end k = k + 1 # previous yield's values. Mirrors compile_yield_stmt's "0" # padding on the function-pointer dispatch path. while assigned < bp_names.length emit(" lv_" + bp_names[assigned] + " = 0;") bp_reset_t = find_var_type(bp_names[assigned]) if bp_reset_t == "bigint" @needs_bigint = 1 emit(" lv_" + bp_names[assigned] + " = sp_bigint_new_int(0);") else emit(" lv_" + bp_names[assigned] + " = 0;") end assigned = assigned + 1 end body = @nd_body[blk]