mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-09 23:29:03 +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);
|
optionsForbidden(options);
|
||||||
|
|
||||||
if (info.fields.len == 0) {
|
if (info.fields.len == 0) {
|
||||||
unreachable;
|
unreachable; // the only possible value is `undefined`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.is_exhaustive) {
|
if (info.is_exhaustive) {
|
||||||
|
|
@ -1289,7 +1289,7 @@ pub fn printValue(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info.fields.len == 0) {
|
if (info.fields.len == 0) {
|
||||||
unreachable;
|
unreachable; // the only possible value is `undefined`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.tag_type) |UnionTagType| {
|
if (info.tag_type) |UnionTagType| {
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ pub fn write(self: *Stringify, v: anytype) Error!void {
|
||||||
return v.jsonStringify(self);
|
return v.jsonStringify(self);
|
||||||
}
|
}
|
||||||
if (enum_info.fields.len == 0) {
|
if (enum_info.fields.len == 0) {
|
||||||
unreachable;
|
unreachable; // the only possible value is `undefined`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enum_info.is_exhaustive) {
|
if (!enum_info.is_exhaustive) {
|
||||||
|
|
@ -424,7 +424,7 @@ pub fn write(self: *Stringify, v: anytype) Error!void {
|
||||||
return v.jsonStringify(self);
|
return v.jsonStringify(self);
|
||||||
}
|
}
|
||||||
if (union_info.fields.len == 0) {
|
if (union_info.fields.len == 0) {
|
||||||
unreachable;
|
unreachable; // the only possible value is `undefined`
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = @typeInfo(T).@"union";
|
const info = @typeInfo(T).@"union";
|
||||||
|
|
|
||||||
|
|
@ -856,7 +856,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
|
||||||
|
|
||||||
try expectEqual(expectedTag, actualTag);
|
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
|
// we only reach this switch if the tags are equal
|
||||||
switch (expected) {
|
switch (expected) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue