Commit a0fb552a

a0fb552aa77bMerged

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

Description

defined? on locals, globals, methods, and constants

DefinedNode was unhandled. Resolve it at compile time to the CRuby label string ("local-variable", "global-variable", "method", "constant", "instance-variable", "expression", ...) or nil (NULL) when the operand is not defined. An assigned global is detected by scanning for a matching global write; a method by the compiler's method table.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
a0fb552aa77b
Parent
525d95cc6ed5

src/analyze.cmodifiedView file

@@ -904,6 +904,7 @@
904904 if (nm && !strcmp(nm, "RUBY_DESCRIPTION")) return TY_STRING;
905905 return TY_UNKNOWN;
906906 }
907+ if (!strcmp(ty, "DefinedNode")) return TY_STRING; /* a label string, or nil (NULL) */
907908 if (!strcmp(ty, "SelfNode")) {
908909 Scope *s = comp_scope_of(c, id);
909910 return s->class_id >= 0 ? ty_object(s->class_id) : TY_UNKNOWN;