fix(stdlib/S2.1b): namespace-qualified parameterized heads [additive]
This commit is contained in:
@@ -752,10 +752,38 @@ const ResolvePass = struct {
|
||||
/// in scope is symbolic (not an author); a name with no user author (builtins
|
||||
/// like `Vector`, undeclared) or only non-head authors is omitted.
|
||||
fn classifyHead(self: *ResolvePass, node: *const ast.Node, name: []const u8, is_raw: bool, ctx: Ctx) void {
|
||||
if (std.mem.indexOfScalar(u8, name, '.')) |first_dot| {
|
||||
const set = self.collectQualifiedHeadAuthors(name, first_dot, ctx.source) orelse return;
|
||||
self.classifyHeadSet(node, set);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_raw and lookupGeneric(ctx.scope, name) != null) return;
|
||||
const set = self.res.collectVisibleAuthors(name, ctx.source, .user_bare_flat);
|
||||
if (set.distinctCount() == 0) return;
|
||||
|
||||
self.classifyHeadSet(node, set);
|
||||
}
|
||||
|
||||
/// `alias.Member(args)` reaches this pass as one `parameterized_type_expr`
|
||||
/// named `alias.Member`. Split like the old lowering path: alias before the
|
||||
/// first dot, member after the last dot, then collect from the namespace
|
||||
/// target's own declarations only.
|
||||
fn collectQualifiedHeadAuthors(self: *ResolvePass, name: []const u8, first_dot: usize, from: []const u8) ?AuthorSet {
|
||||
const alias = name[0..first_dot];
|
||||
const last_dot = std.mem.lastIndexOfScalar(u8, name, '.') orelse first_dot;
|
||||
const member = name[last_dot + 1 ..];
|
||||
if (alias.len == 0 or member.len == 0) return null;
|
||||
|
||||
const edges = self.res.index.namespace_edges orelse return null;
|
||||
const aliases = edges.get(from) orelse return null;
|
||||
const target = aliases.get(alias) orelse return null;
|
||||
const set = self.res.collectNamespaceAuthors(target, member);
|
||||
if (set.distinctCount() == 0) return null;
|
||||
return set;
|
||||
}
|
||||
|
||||
fn classifyHeadSet(self: *ResolvePass, node: *const ast.Node, set: AuthorSet) void {
|
||||
var gs = false;
|
||||
var tf = false;
|
||||
var pr = false;
|
||||
|
||||
Reference in New Issue
Block a user