| author | |
| committer | |
| log | b2f02a820f1ed46721ed55243cead52efed055d7 |
| tree | dd5e19857ff0430a20bcb3f4a333451f9399a66e |
| parent | 6c020cdb767192757b6c4b43e2f14c5394760431 |
The struct might be a top level struct in which case it might not have Zir.
Closes #125482 files changed, 21 insertions(+), 2 deletions(-)
src/Sema.zig+3-1| ... | ... | @@ -27909,7 +27909,9 @@ fn resolveInferredErrorSetTy( |
| 27909 | 27909 | fn semaStructFields(mod: *Module, struct_obj: *Module.Struct) CompileError!void { |
| 27910 | 27910 | const gpa = mod.gpa; |
| 27911 | 27911 | const decl_index = struct_obj.owner_decl; |
| 27912 | const zir = struct_obj.namespace.file_scope.zir; | |
| 27912 | const file_scope = struct_obj.namespace.file_scope; | |
| 27913 | if (file_scope.status != .success_zir) return error.AnalysisFail; | |
| 27914 | const zir = file_scope.zir; | |
| 27913 | 27915 | const extended = zir.instructions.items(.data)[struct_obj.zir_index].extended; |
| 27914 | 27916 | assert(extended.opcode == .struct_decl); |
| 27915 | 27917 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); |
test/compile_errors.zig+18-1| ... | ... | @@ -184,7 +184,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | { |
| 187 | const case = ctx.obj("argument causes error ", .{}); | |
| 187 | const case = ctx.obj("argument causes error", .{}); | |
| 188 | 188 | case.backend = .stage2; |
| 189 | 189 | |
| 190 | 190 | case.addSourceFile("b.zig", |
| ... | ... | @@ -208,6 +208,23 @@ pub fn addCases(ctx: *TestContext) !void { |
| 208 | 208 | }); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | { | |
| 212 | const case = ctx.obj("astgen failure in file struct", .{}); | |
| 213 | case.backend = .stage2; | |
| 214 | ||
| 215 | case.addSourceFile("b.zig", | |
| 216 | \\bad | |
| 217 | ); | |
| 218 | ||
| 219 | case.addError( | |
| 220 | \\pub export fn entry() void { | |
| 221 | \\ _ = (@sizeOf(@import("b.zig"))); | |
| 222 | \\} | |
| 223 | , &[_][]const u8{ | |
| 224 | ":1:1: error: struct field missing type", | |
| 225 | }); | |
| 226 | } | |
| 227 | ||
| 211 | 228 | // TODO test this in stage2, but we won't even try in stage1 |
| 212 | 229 | //ctx.objErrStage1("inline fn calls itself indirectly", |
| 213 | 230 | // \\export fn foo() void { |