From 7b44e8986fa0a8121993ab328b129789127a13bd Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Tue, 28 Apr 2026 13:01:06 +0100 Subject: [PATCH] Sema: remove `void{}` from the language Because this syntax is not heavily used, and the migration can be done with a simple text substitution, I do not believe a `zig fmt` fixup is necessary for this change. Resolves: https://github.com/ziglang/zig/issues/15213 --- src/Sema.zig | 1 - test/cases/compile_errors/bad_void_initializer.zig | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/cases/compile_errors/bad_void_initializer.zig diff --git a/src/Sema.zig b/src/Sema.zig index 467a321df86d73e85aee04fe74833eb3e26e3dd7..f5bbbe4b4112681946d151d1b64e2a6d92ffc48e 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18339,7 +18339,6 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE switch (obj_ty.zigTypeTag(zcu)) { .@"struct" => return sema.structInitEmpty(block, obj_ty, src, src), .array, .vector => return sema.arrayInitEmpty(block, src, obj_ty), - .void => return Air.internedToRef(Value.void.toIntern()), .@"union" => return sema.fail(block, src, "union initializer must initialize one field", .{}), else => return sema.failWithArrayInitNotSupported(block, src, obj_ty), } diff --git a/test/cases/compile_errors/bad_void_initializer.zig b/test/cases/compile_errors/bad_void_initializer.zig new file mode 100644 index 0000000000000000000000000000000000000000..822e57e2e005e263e6957358876f772ca78bd329 --- /dev/null +++ b/test/cases/compile_errors/bad_void_initializer.zig @@ -0,0 +1,7 @@ +comptime { + _ = void{}; +} + +// error +// +// :2:13: error: type 'void' does not support array initialization syntax -- 2.54.0