Commit 8051534c

8051534cb86dMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Module singleton accessor fold: bind args to the resolved class method

A folded Module.accessor.cmethod(args) call now feeds its argument types into the resolved constant's class method during param inference. Without this the method's params stayed TY_UNKNOWN, so the untyped-param backstop dropped the method as unreachable and the folded call site referenced an undefined symbol.

Fixes module_acc_dispatch_param_box (Storage.fetch reached only through the folded Backend.db accessor, with int and string call sites widening its param to poly).

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
8051534cb86d
Parent
83219f2acc5b

src/analyze.cmodifiedView file

@@ -5607,6 +5607,15 @@
56075607 }
56085608 continue;
56095609 }
5610+ /* `Module.accessor.cmethod(args)` folded to a constant: bind args to the
5611+ resolved class method's params (so it is not dropped as untyped). */
5612+ {
5613+ int fold_ci = comp_sg_reader_const(c, recv);
5614+ if (fold_ci >= 0) {
5615+ int fmi = comp_cmethod_in_chain(c, fold_ci, name, NULL);
5616+ if (fmi >= 0) { changed |= bind_call_params(c, id, fmi); continue; }
5617+ }
5618+ }
56105619 /* Class.new -> initialize params; Class.cmethod -> cmethod params */
56115620 {
56125621 const char *rty = nt_type(nt, recv);