Commit 723057ab
723057abc6dcMerged
Ryan Seys <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: diagnose dynamic method_defined? intent
method_defined? is answered at compile time when the receiver is a
class constant and the name is a literal symbol/string (this already
works). The fully dynamic form -- a class held in a variable, or a
runtime method name -- cannot be answered ahead of time: there is no
runtime reflection table, and builtin classes have no enumerable method
set. It previously fell through to the generic unsupported-call node
dump.
Emit a specific diagnostic naming the requirement (a compile-time-known class and literal method name) so the limitation is actionable rather than opaque. This covers an implicit-self call as well (the compile-time resolution likewise only fires for an explicit class-constant receiver, so implicit self is never resolved there). The successful compile-time path is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 723057abc6dc
- Parent
- 913a83318df6
src/codegen_call.cmodifiedView file
} } /* The fully dynamic form (class held in a variable, or a non-literal method name) cannot be answered ahead of time: there is no runtime reflection table, and builtin classes have no enumerable method set. Emit a specific diagnostic rather than a generic unsupported-call node dump. Covers both an explicit receiver and an implicit-self call (recv < 0). */ if (!strcmp(name, "method_defined?")) { unsupported(c, id, "method_defined? (needs a compile-time-known class and literal method name)"); return; } /* Class.const_defined?(:K): compile-time presence check. Constants are recorded in a flat namespace, so this consults the global const and class tables rather than the receiver's own constants. */