add behavior test for while(true) not needing else unreachable

closes #707
This commit is contained in:
Andrew Kelley
2022-12-06 17:57:27 -07:00
parent e7d28344fa
commit b7b905d227
8 changed files with 21 additions and 14 deletions
+7
View File
@@ -364,3 +364,10 @@ test "try terminating an infinite loop" {
_ = try Foo.bar();
} else unreachable);
}
test "while loop with comptime true condition needs no else block to return value with break" {
const x = while (true) {
break @as(u32, 69);
};
try expect(x == 69);
}