aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-05-31 02:32:09 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:58 -0700
commitb2391a7d4425418a29598523dcbdf2bfc9325ecd (patch)
tree4c0fb2197e1d5f02fe3cab697aa08d703cc1a4c0 /src/Sema.zig
parent71c4077c359096d0706a251a10eeae6c41f299ca (diff)
downloadzig-b2391a7d4425418a29598523dcbdf2bfc9325ecd.tar.gz
zig-b2391a7d4425418a29598523dcbdf2bfc9325ecd.zip
Sema: remove opv status from arrays with sentinels
Being able to create a pointer to the non-opv sentinel means that these types have to actually be stored.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 9af9b6eace..bc34109bc9 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -33468,11 +33468,13 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.inferred_error_set_type,
=> null,
- inline .array_type, .vector_type => |seq_type| {
- if (seq_type.len == 0) return (try mod.intern(.{ .aggregate = .{
+ inline .array_type, .vector_type => |seq_type, seq_tag| {
+ const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none;
+ if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
.ty = ty.toIntern(),
.storage = .{ .elems = &.{} },
} })).toValue();
+
if (try sema.typeHasOnePossibleValue(seq_type.child.toType())) |opv| {
return (try mod.intern(.{ .aggregate = .{
.ty = ty.toIntern(),