Commit 8d375f9f
8d375f9fe756Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Namespaced constant read and multiple-assignment target
Resolve a ConstantPathNode read (M::CONST) to the flat constant named by its final path component, in both analyze and codegen. Extend multiple assignment to a ConstantPathTargetNode (a, M::X = 1, 2) by writing the backing cst_ slot, and make an otherwise-unhandled masgn target a hard error instead of a silent skip (which had let an unwritten target read back uninitialized).
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 8d375f9fe756
- Parent
- e24f24ab8675
src/analyze.cmodifiedView file
@@ -916,6 +916,13 @@
916916
}917917
if (!strcmp(ty, "DefinedNode")) return TY_STRING; /* a label string, or nil (NULL) */918918
if (!strcmp(ty, "NumberedReferenceReadNode")) return TY_STRING; /* $1..$9: capture, or nil (NULL) */919+
if (!strcmp(ty, "ConstantPathNode")) {920+
/* M::CONST -> resolve by the final path component (constants register921+
under their unqualified name) */922+
const char *nm = nt_str(nt, id, "name");923+
LocalVar *lv = nm ? comp_const(c, nm) : NULL;924+
return lv ? lv->type : TY_UNKNOWN;925+
}919926
if (!strcmp(ty, "SelfNode")) {920927
Scope *s = comp_scope_of(c, id);921928
return s->class_id >= 0 ? ty_object(s->class_id) : TY_UNKNOWN;src/codegen.cmodifiedView file
Loading diff…