mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
Sema: fix @splat of OPV arrays
This commit is contained in:
parent
58c00a829e
commit
d97441d37e
@ -24581,8 +24581,12 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
|
||||
|
||||
const len = try sema.usizeCast(block, src, dest_ty.arrayLen(zcu));
|
||||
|
||||
// `len == 0` because `[0:s]T` always has a comptime-known splat.
|
||||
if (!dest_ty.hasRuntimeBits(zcu) or len == 0) {
|
||||
if (try sema.typeHasOnePossibleValue(dest_ty)) |val| {
|
||||
return Air.internedToRef(val.toIntern());
|
||||
}
|
||||
|
||||
// We also need this case because `[0:s]T` is not OPV.
|
||||
if (len == 0) {
|
||||
const empty_aggregate = try pt.intern(.{ .aggregate = .{
|
||||
.ty = dest_ty.toIntern(),
|
||||
.storage = .{ .elems = &.{} },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user