Commit edd1240f
edd1240fa8f2Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(analyze): promote tuple element types in method/class returns
return @x, @y, @z materializes as sp_Tuple_int_int_int *,
recorded as tuple:int,int,int in @meth_return_types /
@cls_meth_returns. The promote pass touched simple int slots but
not the inner elems of tuple return entries, so the builder emit
(driven by the ivar slot types — now bigint) produced
sp_Tuple_bigint_bigint_bigint * while the function's declared
return type stayed sp_Tuple_int_int_int *.
Sweep tuple elem types in both promote_meth_returns_table and the @meth_return_types top-level loop.
Promote-mode test count: 546 pass / 47 fail / 25 error -> 547 pass / 47 fail / 24 error. Default raise mode 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- edd1240fa8f2
- Parent
- 6594360f1b95
spinel_analyze.rbmodifiedView file
if @meth_return_types[mi] == "int" @meth_return_types[mi] = "bigint" @needs_bigint = 1 elsif @meth_return_types[mi].start_with?("tuple:") tparts_mr = @meth_return_types[mi][6, @meth_return_types[mi].length - 6].split(",") changed_tup_mr = 0 tpm_i = 0 while tpm_i < tparts_mr.length if tparts_mr[tpm_i] == "int" tparts_mr[tpm_i] = "bigint" @needs_bigint = 1 changed_tup_mr = 1 end tpm_i = tpm_i + 1 end if changed_tup_mr == 1 @meth_return_types[mi] = "tuple:" + tparts_mr.join(",") end end mi = mi + 1 end rets[mj] = "bigint" @needs_bigint = 1 changed = 1 elsif rets[mj].start_with?("tuple:") # Tuple element types: a return like `tuple:int,int,int` (built # by `return @x, @y, @z` when @x..@z are int) holds raw int # slots in the synthesized sp_Tuple_int_int_int struct. With # promote mode lifting the ivars to bigint, the tuple build emit # produces sp_Tuple_bigint_bigint_bigint at the call site, so # the return type slot must move too. tparts_ret = rets[mj][6, rets[mj].length - 6].split(",") changed_tup_ret = 0 tpr_i = 0 while tpr_i < tparts_ret.length if tparts_ret[tpr_i] == "int" tparts_ret[tpr_i] = "bigint" @needs_bigint = 1 changed_tup_ret = 1 end tpr_i = tpr_i + 1 end if changed_tup_ret == 1 rets[mj] = "tuple:" + tparts_ret.join(",") changed = 1 end end mj = mj + 1 end # Promote-mode safety: annotate may have produced stale "int" # entries for nodes whose inferred type derived from cached # state captured before promote_int_to_bigint_globally landed # (SuperNode reading cls_method_return's pre-promotion result, # CallNode chains whose mid-tree return type was cached, etc.). # (SuperNode reading cls_method_return's pre-promotion result). # Sweep `@nd_inferred_type` again and rewrite "int" -> "bigint" # for node kinds whose concrete C emit is always bigint when the # underlying slot is promoted.