This commit is contained in:
2026-08-01 13:10:36 +02:00
parent a8593c00f9
commit 304880a9aa
8 changed files with 1873350 additions and 998499 deletions
+11 -5
View File
@@ -2480,15 +2480,17 @@ parse_for :: proc(parser: ^Parser) -> ast.Stmt_Id {
if _, ok := allow(parser, .At); ok {
pointer_capture = true
}
item, item_ok := allow(parser, .Identifier)
if item_ok {
item := current(parser)
if item.kind == .Identifier || item.kind == .Underscore {
advance(parser)
item_name = item.symbol
} else {
source.add(parser.diagnostics, current(parser).span, "expected a for-loop item capture")
}
if _, ok := allow(parser, .Comma); ok {
index, index_ok := allow(parser, .Identifier)
if index_ok {
index := current(parser)
if index.kind == .Identifier || index.kind == .Underscore {
advance(parser)
index_name = index.symbol
} else {
source.add(parser.diagnostics, current(parser).span, "expected an index capture after ','")
@@ -2538,7 +2540,11 @@ parse_while :: proc(parser: ^Parser) -> ast.Stmt_Id {
skip_newlines(parser)
}
label := parse_optional_loop_label(parser)
body := parse_block(parser)
body := parse_control_body(
parser,
condition,
"a brace-less 'while' body requires the condition to be parenthesized unless it is a function call",
)
id := ast.stmt_id(len(parser.module.statements))
append(&parser.module.statements, ast.Stmt{