add comments to 'unreachable' states

This commit is contained in:
lipfang 2025-11-30 17:58:20 -08:00
parent dcfe553398
commit 08aba84238
3 changed files with 7 additions and 5 deletions

View file

@ -1270,7 +1270,7 @@ pub fn printValue(
optionsForbidden(options);
if (info.fields.len == 0) {
unreachable;
unreachable; // the only possible value is `undefined`
}
if (info.is_exhaustive) {
@ -1289,7 +1289,7 @@ pub fn printValue(
return;
}
if (info.fields.len == 0) {
unreachable;
unreachable; // the only possible value is `undefined`
}
if (info.tag_type) |UnionTagType| {

View file

@ -401,7 +401,7 @@ pub fn write(self: *Stringify, v: anytype) Error!void {
return v.jsonStringify(self);
}
if (enum_info.fields.len == 0) {
unreachable;
unreachable; // the only possible value is `undefined`
}
if (!enum_info.is_exhaustive) {
@ -424,7 +424,7 @@ pub fn write(self: *Stringify, v: anytype) Error!void {
return v.jsonStringify(self);
}
if (union_info.fields.len == 0) {
unreachable;
unreachable; // the only possible value is `undefined`
}
const info = @typeInfo(T).@"union";

View file

@ -856,7 +856,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
try expectEqual(expectedTag, actualTag);
if (union_info.fields.len == 0) unreachable;
if (union_info.fields.len == 0) {
unreachable; // the only possible value is `undefined`
}
// we only reach this switch if the tags are equal
switch (expected) {