compiler: allow @import of ZON without a result type

In particular, this allows importing `build.zig.zon` at comptime.
This commit is contained in:
Mason Remaley
2025-02-15 15:42:59 -08:00
committed by mlugg
parent 1b62a22268
commit 06ee383da9
11 changed files with 302 additions and 37 deletions

View File

@@ -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,