mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
add behavior test for while(true) not needing else unreachable
closes #707
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user