aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-02-01 09:46:29 +0000
committermlugg <mlugg@mlugg.co.uk>2025-02-01 09:46:29 +0000
commitd97441d37ef08813187f1b44ec29612619104585 (patch)
tree3c035a3064550a6f39555596cb0a8191749e3949 /src
parent58c00a829e8acf438b91e9f7e1729ce79be722fa (diff)
downloadzig-d97441d37ef08813187f1b44ec29612619104585.tar.gz
zig-d97441d37ef08813187f1b44ec29612619104585.zip
Sema: fix `@splat` of OPV arrays
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index bc9d5ea55f..caf457a989 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -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 = &.{} },