Sema: check for astgen failures in semaStructFields

The struct might be a top level struct in which case it might not have Zir.

Closes #12548
This commit is contained in:
Veikka Tuominen
2022-08-21 17:07:22 +03:00
parent 6c020cdb76
commit b2f02a820f
2 changed files with 21 additions and 2 deletions
+18 -1
View File
@@ -184,7 +184,7 @@ pub fn addCases(ctx: *TestContext) !void {
}
{
const case = ctx.obj("argument causes error ", .{});
const case = ctx.obj("argument causes error", .{});
case.backend = .stage2;
case.addSourceFile("b.zig",
@@ -208,6 +208,23 @@ pub fn addCases(ctx: *TestContext) !void {
});
}
{
const case = ctx.obj("astgen failure in file struct", .{});
case.backend = .stage2;
case.addSourceFile("b.zig",
\\bad
);
case.addError(
\\pub export fn entry() void {
\\ _ = (@sizeOf(@import("b.zig")));
\\}
, &[_][]const u8{
":1:1: error: struct field missing type",
});
}
// TODO test this in stage2, but we won't even try in stage1
//ctx.objErrStage1("inline fn calls itself indirectly",
// \\export fn foo() void {