Commit 656878a4
656878a4c1edMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified
Description
fix(analyze,codegen): _block fn-ptr csig sees promoted method params
block_params_csig_for_body declared the def's locals from
@nd_scope_names[bid] and walked yield args, but method params
live in @meth_param_names / @cls_meth_params and weren't in
scope. infer_type(yield x) for a param x fell back to "int"
and the emitted forward decl said _block(mrb_int, ...) even when
x's slot had been promoted to bigint.
Two fixes:
-
analyze:
promote_int_to_bigint_globallyruns before precompute_all_scope_decls which re-derives @nd_scope_types. Add a second sweep AFTER precompute that walks scope_types and rewrites "int" -> "bigint" so the IR-exportedSTlines (and thus the codegen-side csig) see promoted slot types. -
codegen:
block_params_csig_for_bodylooks up the enclosing method (top-level via @meth_body_ids, instance via @cls_meth _bodies) and declares its params into the scope alongside the body locals. The yield-walk's infer_type calls then resolve a param reference to its bigint type.
Promote-mode test count: 531 pass / 50 fail / 37 error -> 532 pass / 50 fail / 36 error. Default raise mode 618 / 0 / 0; optcarrot checksum 59662.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 656878a4c1ed
- Parent
- 536eb53e5129
spinel_analyze.rbmodifiedView file
compute_live_instance_methods @analysis_frozen = 1 precompute_all_scope_decls # precompute_all_scope_decls re-derives scope_types from # @meth_param_types and from the local refinement pass; in promote # mode, the latter may have left some method-body locals as "int" # despite the globally-promoted param table. Re-run the scope # types int -> bigint sweep so the IR-exported `ST` lines (and # thus the codegen-side block_params_csig_for_body) see promoted # slot types. if @int_overflow_mode == "promote" sj = 0 while sj < @nd_scope_types.length stj = @nd_scope_types[sj] if stj != "" psj = stj.split("|") chj = 0 ppj = 0 while ppj < psj.length if psj[ppj] == "int" psj[ppj] = "bigint" @needs_bigint = 1 chj = 1 end ppj = ppj + 1 end if chj == 1 @nd_scope_types[sj] = psj.join("|") end end sj = sj + 1 end end annotate_all_node_types # Now that @nd_inferred_type is populated for every reachable # node, we can resolve `recv.method(...)`'s receiver classspinel_codegen.rbmodifiedView file
Loading diff…