Sema: ignore dependency loops in typeinfo decls

This matches stage1 behavior.

Closes #14322
This commit is contained in:
Veikka Tuominen
2023-01-15 14:06:59 +02:00
parent 94be9dcc7f
commit 6b037bad59
2 changed files with 14 additions and 0 deletions

View File

@@ -16258,6 +16258,7 @@ fn typeInfoNamespaceDecls(
for (decls) |decl_index| {
const decl = sema.mod.declPtr(decl_index);
if (decl.kind == .@"usingnamespace") {
if (decl.analysis == .in_progress) continue;
try sema.mod.ensureDeclAnalyzed(decl_index);
var buf: Value.ToTypeBuffer = undefined;
const new_ns = decl.val.toType(&buf).getNamespace().?;

View File

@@ -590,3 +590,16 @@ test "@typeInfo decls and usingnamespace" {
try expectEqualStrings(decls[1].name, "y");
try expectEqualStrings(decls[2].name, "z");
}
test "@typeInfo decls ignore dependency loops" {
const S = struct {
fn Def(comptime T: type) type {
std.debug.assert(@typeInfo(T).Struct.decls.len == 1);
return struct {
const foo = u32;
};
}
usingnamespace Def(@This());
};
_ = S.foo;
}