switch on enum which only has 1 field is comptime known

closes #593
This commit is contained in:
Andrew Kelley
2017-12-05 22:26:17 -05:00
parent bb6b4f8db2
commit f464fe14f4
2 changed files with 21 additions and 0 deletions

View File

@@ -366,3 +366,14 @@ fn doALoopThing(id: EnumWithOneMember) {
test "comparison operator on enum with one member is comptime known" {
doALoopThing(EnumWithOneMember.Eof);
}
const State = enum {
Start,
};
test "switch on enum with one member is comptime known" {
var state = State.Start;
switch (state) {
State.Start => return,
}
@compileError("analysis should not reach here");
}