Commit 7f4aabe1
7f4aabe11729Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): inlined yield function locals declare original name too
compile_yield_method_call_stmt declared the renamed _yN local
in scope but not the original name. Body emit goes through
compile_expr_remap which:
- maps the LV-read's emitted text to
lv_i_y1(renamed) - but consults find_var_type by the unrenamed AST name "i"
Without the original-name declare, find_var_type("i") returned ""
and infer_type fell back to "int", so a while i < @nums.length
inside the inlined body never dispatched through the bigint
arithmetic arm and emitted (lv_i_y1 < sp_IntArray_length(...))
with a pointer/int mismatch.
Also unbox the index in compile_expr_remap's int_array / float_
array [] arm when the index is bigint-typed, so the inlined
@nums[i] emit reaches sp_IntArray_get with a clean mrb_int
subscript.
Promote-mode test count: 516 pass / 48 fail / 54 error -> 518 pass / 48 fail / 52 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 7f4aabe11729
- Parent
- 4dfadf3d5f26
spinel_codegen.rbmodifiedView file
param_map_from.push(flocals_n[k]) param_map_to.push(tname) declare_var(tname, flocals_t[k]) # Also expose the original local name so the body emit's # find_var_type lookup (via the unrenamed AST node) returns # the right type. Mirrors the param declare pair above. declare_var(flocals_n[k], flocals_t[k]) k = k + 1 end end end if rt_r == "int_array" && mname == "[]" arg_r = compile_expr_remap_arg0(nid, map_from, map_to) # Unbox bigint index — promote mode may have widened the # iter counter local to sp_Bigint *. args_id_ir = @nd_arguments[nid] if args_id_ir >= 0 aa_ir = get_args(args_id_ir) if aa_ir.length > 0 && infer_type(aa_ir[0]) == "bigint" @needs_bigint = 1 arg_r = "sp_bigint_to_int((sp_Bigint *)" + arg_r + ")" end end return "sp_IntArray_get(" + rc_r + ", " + arg_r + ")" end if rt_r == "float_array" && mname == "[]" arg_r = compile_expr_remap_arg0(nid, map_from, map_to) args_id_fr = @nd_arguments[nid] if args_id_fr >= 0 aa_fr = get_args(args_id_fr) if aa_fr.length > 0 && infer_type(aa_fr[0]) == "bigint" @needs_bigint = 1 arg_r = "sp_bigint_to_int((sp_Bigint *)" + arg_r + ")" end end return "sp_FloatArray_get(" + rc_r + ", " + arg_r + ")" end if (rt_r == "str_array" || rt_r == "int_array" || rt_r == "sym_array") && (mname == "length" || mname == "size")