mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
add comments to 'unreachable' states
This commit is contained in:
parent
dcfe553398
commit
08aba84238
3 changed files with 7 additions and 5 deletions
|
|
@ -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| {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue