Commit 87bc59b8
87bc59b8d6b5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): inlined yield expr-form coerces tail + declares original local
compile_yield_call_expr declared the renamed _yN locals in
scope but not the original names, so find_var_type inside the
inlined body returned "" for an unrenamed AST read and missed the
promote-mode bigint slot type.
Also coerce the last-expression value when its inferred type
differs from the declared return type (bigint <-> int) — a
literal-int tail like 42 against a bigint return slot now wraps
through sp_bigint_new_int.
Promote-mode test count: 519 pass / 49 fail / 50 error -> 520 pass / 49 fail / 49 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 87bc59b8d6b5
- Parent
- 9c714398c5e6
spinel_codegen.rbmodifiedView file
param_map_from.push(flocals_n[kf]) param_map_to.push(tname) declare_var(tname, flocals_t[kf]) # Also expose the original name so find_var_type lookups in # the inlined body (which sees the unrenamed AST node) find # the right type — mirrors compile_yield_call_stmt / # compile_yield_method_call_stmt. declare_var(flocals_n[kf], flocals_t[kf]) kf = kf + 1 end end compile_stmt_with_block(last_y, blk, bp_names, param_map_from, param_map_to) else # Expression-shaped: capture the value via compile_expr_remap. emit(" " + result_tmp + " = " + compile_expr_remap(last_y, param_map_from, param_map_to) + ";") last_val_yc = compile_expr_remap(last_y, param_map_from, param_map_to) last_t_yc = infer_type(last_y) if base_type(rt_yc) == "bigint" && last_t_yc == "int" @needs_bigint = 1 last_val_yc = "sp_bigint_new_int(" + last_val_yc + ")" elsif base_type(rt_yc) == "int" && last_t_yc == "bigint" @needs_bigint = 1 last_val_yc = "sp_bigint_to_int((sp_Bigint *)" + last_val_yc + ")" end emit(" " + result_tmp + " = " + last_val_yc + ";") end end end