authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-05-31 02:32:09-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:58-07:00
logb2391a7d4425418a29598523dcbdf2bfc9325ecd
tree4c0fb2197e1d5f02fe3cab697aa08d703cc1a4c0
parent71c4077c359096d0706a251a10eeae6c41f299ca

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.

2 files changed, 7 insertions(+), 4 deletions(-)

src/Sema.zig+4-2
......@@ -33468,11 +33468,13 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3346833468 .inferred_error_set_type,
3346933469 => null,
3347033470
33471 inline .array_type, .vector_type => |seq_type| {
33472 if (seq_type.len == 0) return (try mod.intern(.{ .aggregate = .{
33471 inline .array_type, .vector_type => |seq_type, seq_tag| {
33472 const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none;
33473 if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
3347333474 .ty = ty.toIntern(),
3347433475 .storage = .{ .elems = &.{} },
3347533476 } })).toValue();
33477
3347633478 if (try sema.typeHasOnePossibleValue(seq_type.child.toType())) |opv| {
3347733479 return (try mod.intern(.{ .aggregate = .{
3347833480 .ty = ty.toIntern(),
src/type.zig+3-2
......@@ -2479,8 +2479,9 @@ pub const Type = struct {
24792479 .inferred_error_set_type,
24802480 => return null,
24812481
2482 inline .array_type, .vector_type => |seq_type| {
2483 if (seq_type.len == 0) return (try mod.intern(.{ .aggregate = .{
2482 inline .array_type, .vector_type => |seq_type, seq_tag| {
2483 const has_sentinel = seq_tag == .array_type and seq_type.sentinel != .none;
2484 if (seq_type.len + @boolToInt(has_sentinel) == 0) return (try mod.intern(.{ .aggregate = .{
24842485 .ty = ty.toIntern(),
24852486 .storage = .{ .elems = &.{} },
24862487 } })).toValue();