fix: broken conditionals

This commit is contained in:
Brett Broadhurst 2026-03-30 05:44:35 -06:00
parent b231e66b49
commit 97a43f63eb
Failed to generate hash of commit
33 changed files with 358 additions and 313 deletions

View file

@ -91,6 +91,40 @@ test "compiler: constant cycle detection" {
);
}
test "compiler: final else case" {
try testEqual(
\\{true:
\\- else:
\\ False
\\- 1 == 1:
\\ Woops!
\\}
,
\\<STDIN>:2:3: error: 'else' case should always be the final case in conditional
\\2 | - else:
\\ | ^
\\
);
}
test "compiler: final else case 2" {
try testEqual(
\\{
\\- true:
\\ True
\\- else:
\\ False
\\- else:
\\ False
\\}
,
\\<STDIN>:4:3: error: 'else' case should always be the final case in conditional
\\4 | - else:
\\ | ^
\\
);
}
fn testEqual(source_bytes: [:0]const u8, expected_error: []const u8) !void {
const gpa = std.testing.allocator;
var arena_allocator = std.heap.ArenaAllocator.init(gpa);