From 74d6a66a2d44a1393a1676fcdfe4abe58e6ef4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 10 Feb 2026 14:45:37 +0000 Subject: [PATCH] parser: port test "nosuspend block" Implement nosuspend statement in expectStatement. Co-Authored-By: Claude Opus 4.6 (1M context) --- parser.c | 9 +++++++++ parser_test.zig | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/parser.c b/parser.c index 484220c2e4..0b9440a228 100644 --- a/parser.c +++ b/parser.c @@ -1912,6 +1912,15 @@ static AstNodeIndex expectStatement(Parser* p, bool allow_defer_var) { }); } case TOKEN_KEYWORD_NOSUSPEND: + return addNode(&p->nodes, + (AstNodeItem) { + .tag = AST_NODE_NOSUSPEND, + .main_token = nextToken(p), + .data = { + .lhs = expectBlockExprStatement(p), + .rhs = 0, + }, + }); case TOKEN_KEYWORD_SUSPEND: case TOKEN_KEYWORD_ENUM: case TOKEN_KEYWORD_STRUCT: diff --git a/parser_test.zig b/parser_test.zig index e12627adf8..98058ad810 100644 --- a/parser_test.zig +++ b/parser_test.zig @@ -1799,6 +1799,17 @@ test "zig fmt: if-else with comment before else" { ); } +test "zig fmt: nosuspend block" { + try testCanonical( + \\pub fn main() anyerror!void { + \\ nosuspend { + \\ var foo: Foo = .{ .bar = 42 }; + \\ } + \\} + \\ + ); +} + test "zig fmt: top-level tuple function call type" { try testCanonical( \\foo()