authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-01 09:46:29+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-01 09:46:29+00:00
logd97441d37ef08813187f1b44ec29612619104585
tree3c035a3064550a6f39555596cb0a8191749e3949
parent58c00a829e8acf438b91e9f7e1729ce79be722fa
signaturelock-open Commit is signed but in an unrecognized format.

Sema: fix `@splat` of OPV arrays


1 files changed, 6 insertions(+), 2 deletions(-)

src/Sema.zig+6-2
......@@ -24581,8 +24581,12 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2458124581
2458224582 const len = try sema.usizeCast(block, src, dest_ty.arrayLen(zcu));
2458324583
24584 // `len == 0` because `[0:s]T` always has a comptime-known splat.
24585 if (!dest_ty.hasRuntimeBits(zcu) or len == 0) {
24584 if (try sema.typeHasOnePossibleValue(dest_ty)) |val| {
24585 return Air.internedToRef(val.toIntern());
24586 }
24587
24588 // We also need this case because `[0:s]T` is not OPV.
24589 if (len == 0) {
2458624590 const empty_aggregate = try pt.intern(.{ .aggregate = .{
2458724591 .ty = dest_ty.toIntern(),
2458824592 .storage = .{ .elems = &.{} },