authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-05 20:34:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:42:29-07:00
log9626811725ba7bb979559b718492b1fbe7fc0578
treeaf2b94fedcaf24dea546529312454b5fdcb2f45e
parent31aee50c1a96b7e72b42ee885636b27fbcac8eb4

Sema: add typeHasOnePossibleValue logic for InternPool


1 files changed, 16 insertions(+), 3 deletions(-)

src/Sema.zig+16-3
...@@ -32950,14 +32950,27 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -32950,14 +32950,27 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
32950 }32950 }
32951 },32951 },
32952 .ptr_type => return null,32952 .ptr_type => return null,
32953 .array_type => @panic("TODO"),32953 .array_type => |array_type| {
32954 if (array_type.len == 0)
32955 return Value.initTag(.empty_array);
32956 if ((try sema.typeHasOnePossibleValue(array_type.child.toType())) != null) {
32957 return Value.initTag(.the_only_possible_value);
32958 }
32959 return null;
32960 },
32954 .vector_type => |vector_type| {32961 .vector_type => |vector_type| {
32955 if (vector_type.len == 0) return Value.initTag(.empty_array);32962 if (vector_type.len == 0) return Value.initTag(.empty_array);
32956 if (try sema.typeHasOnePossibleValue(vector_type.child.toType())) |v| return v;32963 if (try sema.typeHasOnePossibleValue(vector_type.child.toType())) |v| return v;
32957 return null;32964 return null;
32958 },32965 },
32959 .opt_type => @panic("TODO"),32966 .opt_type => |child| {
32960 .error_union_type => @panic("TODO"),32967 if (child.toType().isNoReturn()) {
32968 return Value.null;
32969 } else {
32970 return null;
32971 }
32972 },
32973 .error_union_type => return null,
32961 .simple_type => |t| switch (t) {32974 .simple_type => |t| switch (t) {
32962 .f16,32975 .f16,
32963 .f32,32976 .f32,