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 {
3295032950 }
3295132951 },
3295232952 .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 },
3295432961 .vector_type => |vector_type| {
3295532962 if (vector_type.len == 0) return Value.initTag(.empty_array);
3295632963 if (try sema.typeHasOnePossibleValue(vector_type.child.toType())) |v| return v;
3295732964 return null;
3295832965 },
32959 .opt_type => @panic("TODO"),
32960 .error_union_type => @panic("TODO"),
32966 .opt_type => |child| {
32967 if (child.toType().isNoReturn()) {
32968 return Value.null;
32969 } else {
32970 return null;
32971 }
32972 },
32973 .error_union_type => return null,
3296132974 .simple_type => |t| switch (t) {
3296232975 .f16,
3296332976 .f32,