Files
sx/examples/0831-modules-namespace-alias-carry.sx
agra ee00db849c lang: qualified namespace members in value position + alias carry
Two coupled capabilities on the road to the std restructure
(current/PLAN-STDLIB.md, issue 0114):

1. alias.Type.method() / alias.Type as a call head, alias.CONST, and
   alias.Enum.variant now resolve — previously only alias.fn() and
   type-position alias.Type worked. objectIsValue treats an
   alias-rooted field_access as a type head; the call path strips the
   alias to the existing Type.method machinery; lowerFieldAccess
   resolves alias.CONST pinned to the target module and alias.Enum.x
   as a typed enum literal; resolveTypeWithBindings resolves qualified
   type_exprs pinned to the target.

2. The carry rule: namespaceAliasTarget resolves an alias from the
   file's own edges first, then from DIRECT flat imports (one level),
   diagnosing two distinct carried targets as ambiguous. All qualified
   shapes work through a carried alias — the std.sx namespace tail
   (mem.GPA.init() etc.) is now expressible.

Regression: examples/0831-modules-namespace-alias-carry.sx (direct +
carried, all seven shapes).
2026-06-11 05:52:10 +03:00

21 lines
881 B
Plaintext

// Namespace aliases are module surface: a `ns :: #import` declared by a
// module is usable by that module's DIRECT flat importers (the carry rule —
// no `pub` keyword). Covers every qualified shape through BOTH a direct and
// a carried alias: plain fn, struct static method + instance method, type
// annotation, enum variant, module const, generic struct.
#import "modules/std.sx";
#import "0831-modules-namespace-alias-carry/facade.sx";
main :: () {
print("{} ", r.helper()); // plain fn (carried)
t := r.Thing.init(); // static method
print("{} ", t.get());
x : r.Thing = r.Thing.init(); // type annotation
print("{} ", x.v);
print("{} ", r.LIMIT); // module const
print("{} ", r.Color.green); // enum variant
b := r.Box(s64).{ item = 3 }; // generic struct
print("{}\n", b.item);
}