From 06ee383da9a23016dcb25ff7cb6811e3dc2c387e Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Sat, 15 Feb 2025 15:42:59 -0800 Subject: compiler: allow `@import` of ZON without a result type In particular, this allows importing `build.zig.zon` at comptime. --- src/Type.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Type.zig') diff --git a/src/Type.zig b/src/Type.zig index 3b31337587..ed0df5965f 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -3589,7 +3589,10 @@ pub fn typeDeclSrcLine(ty: Type, zcu: *Zcu) ?u32 { }; const info = tracked.resolveFull(&zcu.intern_pool) orelse return null; const file = zcu.fileByIndex(info.file); - const zir = file.zir.?; + const zir = switch (file.getMode()) { + .zig => file.zir.?, + .zon => return 0, + }; const inst = zir.instructions.get(@intFromEnum(info.inst)); return switch (inst.tag) { .struct_init, .struct_init_ref => zir.extraData(Zir.Inst.StructInit, inst.data.pl_node.payload_index).data.abs_line, -- cgit v1.2.3