From ebed9316c50b20e12631124d568bf9de8a8b6c11 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 6 Oct 2026 07:51:24 -0400 Subject: [PATCH] Type: fix vector size mismatch vs clang This operation used to be implied by the old incorrect alignment calculation, but seems to apply even when the alignment is saturated. Closes #37110 --- src/Type.zig | 5 ++++- test/behavior/error.zig | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Type.zig b/src/Type.zig index b7312967fd3ea85bd1f0f20062649a7ff5a53bfa..2c207738b8f55cae37a5a120b68d968fa51e1f66 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -1151,7 +1151,10 @@ pub fn abiSize(ty: Type, zcu: *const Zcu) u64 { std.zig.target.compilerRtFloatAbi(target, elem_ty.floatBits(target)) else .hard) { - .hard => @divCeil(vec.len * elem_ty.bitSize(zcu), 8), + .hard => switch (vec.len * elem_ty.bitSize(zcu)) { + 0 => return 0, + else => |bits| std.math.ceilPowerOfTwoAssert(u32, @intCast(@divCeil(bits, 8))), + }, .soft => vec.len * elem_ty.abiSize(zcu), }, .stage2_c, .stage2_wasm => vec.len * elem_ty.abiSize(zcu), diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 46f7871a8281f76841f15f85b8d78f9f3db9f6bf..132193c85b777beabe63fad397d92d8d8e03918a 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -1138,3 +1138,9 @@ test "@errorCast into other inferred error set" { const non_err: Ies!u32 = @errorCast(@as(error{}!u32, 123)); try expect(try non_err == 123); } + +test "error union with vector type" { + var x: anyerror!@Vector(5, f64) = undefined; + x = error.Expected; + try expect(x == error.Expected); +} -- 2.54.0