zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b991b868ae2d6719dbe2e36f95c6d2cb799d8810 (tree)
parent 88ae1d9aeca6441f2c905bbde61d399025c63242
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 20 May 2026 12:26:44 -0700

Configuration: prevent ObjectFormat enum mismatch

Diffstat:
Mlib/std/Build/Configuration.zig | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig @@ -2437,6 +2437,7 @@ pub const TargetQuery = struct { }; } }; + pub const ObjectFormat = enum(u4) { c, coff, @@ -2451,8 +2452,17 @@ pub const TargetQuery = struct { default, pub fn init(x: ?std.Target.ObjectFormat) @This() { - // TODO comptime assert the enums match - return @enumFromInt(@intFromEnum(x orelse return .default)); + return switch (x orelse return .default) { + .c => .c, + .coff => .coff, + .elf => .elf, + .hex => .hex, + .macho => .macho, + .plan9 => .plan9, + .raw => .raw, + .spirv => .spirv, + .wasm => .wasm, + }; } pub fn unwrap(this: @This()) ?std.Target.ObjectFormat {