parser: warn on missing for loop payload, recover from invalid global error set access

This commit is contained in:
Veikka Tuominen
2021-02-22 10:04:05 +02:00
parent 621ad241d6
commit 67dac2936c
3 changed files with 54 additions and 12 deletions

View File

@@ -4215,6 +4215,8 @@ test "recovery: invalid global error set access" {
\\}
, &[_]Error{
.expected_token,
.expected_token,
.invalid_and,
});
}
@@ -4273,6 +4275,20 @@ test "recovery: missing block after for/while loops" {
});
}
test "recovery: missing for payload" {
try testError(
\\comptime {
\\ const a = for(a) {};
\\ const a: for(a) {};
\\ for(a) {}
\\}
, &[_]Error{
.expected_loop_payload,
.expected_loop_payload,
.expected_loop_payload,
});
}
const std = @import("std");
const mem = std.mem;
const warn = std.debug.warn;