parser: implement for loops, port for/while loop test

Implement in parser.c:
- forPrefix: parse for input expressions and capture variables
- parseForExpr: for_simple and for AST nodes with optional else
- Handle for and while in parsePrimaryTypeExpr for top-level usage

Remove stale cppcheck knownConditionTrueFalse suppression.

Port test "top-level for/while loop".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-02-10 19:23:30 +00:00
parent 40b7c19848
commit 37ae8b01d1
3 changed files with 116 additions and 8 deletions

View File

@@ -624,6 +624,17 @@ test "zig fmt: respect line breaks before functions" {
);
}
test "zig fmt: top-level for/while loop" {
try testCanonical(
\\for (foo) |_| foo
\\
);
try testCanonical(
\\while (foo) |_| foo
\\
);
}
test "zig fmt: simple top level comptime block" {
try testCanonical(
\\// line comment