Commit b4021bb4

b4021bb463c7Merged

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

Description

analyze/codegen: handle ConstantPathNode for class method calls

Extend Class.cmethod dispatch and return type inference to also handle M::Sub.cmethod (ConstantPathNode receiver), resolving the class by its final path component. Previously only ConstantReadNode was handled, causing deep-namespaced class method calls to fall through to unsupported-call error.

Fixes const_path_deep_nesting and similar tests.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
b4021bb463c7
Parent
cf73c8788f51

src/analyze.cmodifiedView file

@@ -527,10 +527,10 @@
527527 return TY_INT;
528528 }
529529
530- /* Class.cmethod(...) -> the class method's return type */
530+ /* Class.cmethod(...) / M::Sub.cmethod(...) -> the class method's return type */
531531 if (recv >= 0) {
532532 const char *rty = nt_type(nt, recv);
533- if (rty && !strcmp(rty, "ConstantReadNode")) {
533+ if (rty && (!strcmp(rty, "ConstantReadNode") || !strcmp(rty, "ConstantPathNode"))) {
534534 int ci = comp_class_index(c, nt_str(nt, recv, "name"));
535535 if (ci >= 0) {
536536 int mi = comp_cmethod_in_chain(c, ci, name, NULL);