Commit b498aea6
b498aea6aba1Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): method-level rescue body coerces int<->bigint into result tmp
compile_body_into (the helper used by method-level BeginNode +
rescue paths to capture the begin / rescue tail into ret_tmp)
emitted ret_tmp = compile_expr(last); without coercing. A
promote-mode method whose declared return is bigint and whose
rescue body returns -1 produced _t1 = -1LL; against a bigint
slot.
Coerce in both directions when the inferred last-expression type doesn't match return_type's base. compile_rescue_chain_into reuses compile_body_into recursively, so the fix covers both the begin arm and each rescue arm.
Promote-mode test count: 524 pass / 49 fail / 45 error -> 526 pass / 49 fail / 43 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- b498aea6aba1
- Parent
- ed79989191a8
spinel_codegen.rbmodifiedView file
end end expr = compile_expr(last) last_t_cbi = infer_type(last) if base_type(return_type) == "bigint" && last_t_cbi == "int" @needs_bigint = 1 expr = "sp_bigint_new_int(" + expr + ")" elsif base_type(return_type) == "int" && last_t_cbi == "bigint" @needs_bigint = 1 expr = "sp_bigint_to_int((sp_Bigint *)" + expr + ")" end emit(" " + ret_tmp + " = " + expr + ";") end