fix: simple knot tests
This commit is contained in:
parent
9ca2200448
commit
cd94a43cc9
7 changed files with 75 additions and 41 deletions
23
src/Sema.zig
23
src/Sema.zig
|
|
@ -90,7 +90,7 @@ pub fn lookupInNamespace(
|
|||
var scope: ?*Module.Namespace = namespace;
|
||||
while (scope) |s| : (scope = s.parent) {
|
||||
if (s.decls.get(ident)) |decl| switch (decl.tag) {
|
||||
.knot => return .{ .knot = .{
|
||||
.knot, .stitch => return .{ .knot = .{
|
||||
.namespace = decl.namespace.?,
|
||||
.const_index = ident,
|
||||
} },
|
||||
|
|
@ -814,6 +814,27 @@ pub fn analyzeTopLevelDecl(
|
|||
try analyzeNestedDecl(sema, child_namespace, st);
|
||||
}
|
||||
},
|
||||
.decl_stitch => {
|
||||
const child_namespace = try sema.module.createNamespace(namespace);
|
||||
const gop = try namespace.decls.getOrPut(sema.arena, decl_name);
|
||||
if (gop.found_existing) {
|
||||
return sema.fail(src_loc, "duplicate identifier", .{});
|
||||
} else {
|
||||
gop.value_ptr.* = .{
|
||||
.tag = .stitch,
|
||||
.decl_inst = extra.value,
|
||||
.args_count = 0,
|
||||
.namespace = child_namespace,
|
||||
};
|
||||
}
|
||||
|
||||
try sema.module.queueWorkItem(.{
|
||||
.tag = .stitch,
|
||||
.decl_name = decl_name,
|
||||
.inst_index = extra.value,
|
||||
.namespace = child_namespace,
|
||||
});
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue