Commit 1de81c21

1de81c21d7a8Merged

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

Description

Merge pull request #1489 from ryanseys/rs-method-defined

Diagnose dynamic method_defined? intent

Details

Commit
1de81c21d7a8
Parent
9fbcee1e25a2
Merge parent
723057abc6dc

src/codegen_call.cmodifiedView file

@@ -6866,6 +6866,16 @@
68666866 }
68676867 }
68686868
6869+ /* The fully dynamic form (class held in a variable, or a non-literal method
6870+ name) cannot be answered ahead of time: there is no runtime reflection
6871+ table, and builtin classes have no enumerable method set. Emit a specific
6872+ diagnostic rather than a generic unsupported-call node dump. Covers both an
6873+ explicit receiver and an implicit-self call (recv < 0). */
6874+ if (!strcmp(name, "method_defined?")) {
6875+ unsupported(c, id, "method_defined? (needs a compile-time-known class and literal method name)");
6876+ return;
6877+ }
6878+
68696879 /* Class.const_defined?(:K): compile-time presence check. Constants are
68706880 recorded in a flat namespace, so this consults the global const and class
68716881 tables rather than the receiver's own constants. */