mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
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.
This commit is contained in:
parent
71c4077c35
commit
b2391a7d44
@ -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(),
|
||||
|
||||
@ -2479,8 +2479,9 @@ pub const Type = struct {
|
||||
.inferred_error_set_type,
|
||||
=> return 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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user