From b991b868ae2d6719dbe2e36f95c6d2cb799d8810 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 20 May 2026 12:26:44 -0700 Subject: [PATCH] Configuration: prevent ObjectFormat enum mismatch --- lib/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 index 2ad1cf4d03dd6d56a2c8f125a66dbf6703758915..8a1100fa1d3cbce7f2db220165037c7a51a6d619 100644 --- 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 { -- 2.54.0