authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-24 13:34:33-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-04-24 13:34:33-04:00
log29e5e98eed2161c37edbce41b96c2999eb1f3177
treeaf80f2749253cc4f5c61c14c9f37519dc9146ab8
parent4ec6d174adc038741f1274d157f5253752eb8d51
parenteabf378a56e0cd9720f43c36b85025228c4406d8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8606 from LemonBoy/suspend-block

stage1: Require a block after suspend

10 files changed, 122 insertions(+), 91 deletions(-)

doc/langref.html.in+5-5
......@@ -6528,7 +6528,7 @@ test "suspend with no resume" {
65286528
65296529fn func() void {
65306530 x += 1;
6531 suspend;
6531 suspend {}
65326532 // This line is never reached because the suspend has no matching resume.
65336533 x += 1;
65346534}
......@@ -6593,7 +6593,7 @@ fn testResumeFromSuspend(my_result: *i32) void {
65936593 resume @frame();
65946594 }
65956595 my_result.* += 1;
6596 suspend;
6596 suspend {}
65976597 my_result.* += 1;
65986598}
65996599 {#code_end#}
......@@ -6632,7 +6632,7 @@ fn amain() void {
66326632}
66336633
66346634fn func() void {
6635 suspend;
6635 suspend {}
66366636}
66376637 {#code_end#}
66386638 <p>
......@@ -6934,7 +6934,7 @@ test "async fn pointer in a struct field" {
69346934fn func(y: *i32) void {
69356935 defer y.* += 2;
69366936 y.* += 1;
6937 suspend;
6937 suspend {}
69386938}
69396939 {#code_end#}
69406940 {#header_close#}
......@@ -7667,7 +7667,7 @@ test "heap allocated frame" {
76677667}
76687668
76697669fn func() void {
7670 suspend;
7670 suspend {}
76717671}
76727672 {#code_end#}
76737673 {#header_close#}
lib/std/event/rwlock.zig+2-2
......@@ -264,7 +264,7 @@ var shared_test_data = [1]i32{0} ** 10;
264264var shared_test_index: usize = 0;
265265var shared_count: usize = 0;
266266fn writeRunner(lock: *RwLock) callconv(.Async) void {
267 suspend; // resumed by onNextTick
267 suspend {} // resumed by onNextTick
268268
269269 var i: usize = 0;
270270 while (i < shared_test_data.len) : (i += 1) {
......@@ -281,7 +281,7 @@ fn writeRunner(lock: *RwLock) callconv(.Async) void {
281281 }
282282}
283283fn readRunner(lock: *RwLock) callconv(.Async) void {
284 suspend; // resumed by onNextTick
284 suspend {} // resumed by onNextTick
285285 std.time.sleep(1);
286286
287287 var i: usize = 0;
lib/std/zig/parse.zig+2-1
......@@ -852,7 +852,7 @@ const Parser = struct {
852852 /// <- KEYWORD_comptime? VarDecl
853853 /// / KEYWORD_comptime BlockExprStatement
854854 /// / KEYWORD_nosuspend BlockExprStatement
855 /// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)
855 /// / KEYWORD_suspend BlockExprStatement
856856 /// / KEYWORD_defer BlockExprStatement
857857 /// / KEYWORD_errdefer Payload? BlockExprStatement
858858 /// / IfStatement
......@@ -892,6 +892,7 @@ const Parser = struct {
892892 },
893893 .keyword_suspend => {
894894 const token = p.nextToken();
895 // TODO remove this special case when 0.9.0 is released.
895896 const block_expr: Node.Index = if (p.eatToken(.semicolon) != null)
896897 0
897898 else
lib/std/zig/parser_test.zig+33-3
......@@ -40,6 +40,21 @@ test "zig fmt: rewrite inline functions as callconv(.Inline)" {
4040 );
4141}
4242
43// TODO Remove this after zig 0.9.0 is released.
44test "zig fmt: rewrite suspend without block expression" {
45 try testTransform(
46 \\fn foo() void {
47 \\ suspend;
48 \\}
49 \\
50 ,
51 \\fn foo() void {
52 \\ suspend {}
53 \\}
54 \\
55 );
56}
57
4358test "zig fmt: simple top level comptime block" {
4459 try testCanonical(
4560 \\// line comment
......@@ -3665,9 +3680,9 @@ test "zig fmt: async functions" {
36653680 \\fn simpleAsyncFn() void {
36663681 \\ const a = async a.b();
36673682 \\ x += 1;
3668 \\ suspend;
3683 \\ suspend {}
36693684 \\ x += 1;
3670 \\ suspend;
3685 \\ suspend {}
36713686 \\ const p: anyframe->void = async simpleAsyncFn() catch unreachable;
36723687 \\ await p;
36733688 \\}
......@@ -5022,6 +5037,21 @@ test "recovery: invalid comptime" {
50225037 });
50235038}
50245039
5040test "recovery: missing block after suspend" {
5041 // TODO Enable this after zig 0.9.0 is released.
5042 if (true) return error.SkipZigTest;
5043
5044 try testError(
5045 \\fn foo() void {
5046 \\ suspend;
5047 \\ nosuspend;
5048 \\}
5049 , &[_]Error{
5050 .expected_block_or_expr,
5051 .expected_block_or_expr,
5052 });
5053}
5054
50255055test "recovery: missing block after for/while loops" {
50265056 try testError(
50275057 \\test "" { while (foo) }
......@@ -5165,7 +5195,7 @@ fn testError(source: []const u8, expected_errors: []const Error) !void {
51655195 var tree = try std.zig.parse(std.testing.allocator, source);
51665196 defer tree.deinit(std.testing.allocator);
51675197
5168 std.testing.expect(tree.errors.len == expected_errors.len);
5198 std.testing.expectEqual(expected_errors.len, tree.errors.len);
51695199 for (expected_errors) |expected, i| {
51705200 std.testing.expectEqual(expected, tree.errors[i].tag);
51715201 }
lib/std/zig/render.zig+6-1
......@@ -269,7 +269,12 @@ fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.I
269269 try renderToken(ais, tree, suspend_token, .space);
270270 return renderExpression(gpa, ais, tree, body, space);
271271 } else {
272 return renderToken(ais, tree, suspend_token, space);
272 // TODO remove this special case when 0.9.0 is released.
273 assert(space == .semicolon);
274 try renderToken(ais, tree, suspend_token, .space);
275 try ais.writer().writeAll("{}");
276 try ais.insertNewline();
277 return;
273278 }
274279 },
275280
src/stage1/ir.cpp+7-9
......@@ -9534,7 +9534,7 @@ static IrInstSrc *ir_gen_nosuspend(IrBuilderSrc *irb, Scope *parent_scope, AstNo
95349534
95359535 Scope *child_scope = create_nosuspend_scope(irb->codegen, node, parent_scope);
95369536 // purposefully pass null for result_loc and let EndExpr handle it
9537 return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr);
9537 return ir_gen_node_extra(irb, node->data.nosuspend_expr.expr, child_scope, lval, nullptr);
95389538}
95399539
95409540static IrInstSrc *ir_gen_return_from_block(IrBuilderSrc *irb, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) {
......@@ -10199,14 +10199,12 @@ static IrInstSrc *ir_gen_suspend(IrBuilderSrc *irb, Scope *parent_scope, AstNode
1019910199 }
1020010200
1020110201 IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(irb, parent_scope, node);
10202 if (node->data.suspend.block != nullptr) {
10203 ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope);
10204 Scope *child_scope = &suspend_scope->base;
10205 IrInstSrc *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope);
10206 if (susp_res == irb->codegen->invalid_inst_src)
10207 return irb->codegen->invalid_inst_src;
10208 ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res));
10209 }
10202 ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope);
10203 Scope *child_scope = &suspend_scope->base;
10204 IrInstSrc *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope);
10205 if (susp_res == irb->codegen->invalid_inst_src)
10206 return irb->codegen->invalid_inst_src;
10207 ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res));
1021010208
1021110209 return ir_mark_gen(ir_build_suspend_finish_src(irb, parent_scope, node, begin));
1021210210}
src/stage1/parser.cpp+1-4
......@@ -946,10 +946,7 @@ static AstNode *ast_parse_statement(ParseContext *pc) {
946946
947947 Token *suspend = eat_token_if(pc, TokenIdKeywordSuspend);
948948 if (suspend != nullptr) {
949 AstNode *statement = nullptr;
950 if (eat_token_if(pc, TokenIdSemicolon) == nullptr)
951 statement = ast_expect(pc, ast_parse_block_expr_statement);
952
949 AstNode *statement = ast_expect(pc, ast_parse_block_expr_statement);
953950 AstNode *res = ast_create_node(pc, NodeTypeSuspend, suspend);
954951 res->data.suspend.block = statement;
955952 return res;
test/compile_errors.zig+7-7
......@@ -1021,7 +1021,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10211021 \\export fn entry() void {
10221022 \\ nosuspend {
10231023 \\ const bar = async foo();
1024 \\ suspend;
1024 \\ suspend {}
10251025 \\ resume bar;
10261026 \\ }
10271027 \\}
......@@ -2120,7 +2120,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
21202120 \\ non_async_fn = func;
21212121 \\}
21222122 \\fn func() void {
2123 \\ suspend;
2123 \\ suspend {}
21242124 \\}
21252125 , &[_][]const u8{
21262126 "tmp.zig:5:1: error: 'func' cannot be async",
......@@ -2198,7 +2198,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
21982198 \\ var x: anyframe = &f;
21992199 \\}
22002200 \\fn func() void {
2201 \\ suspend;
2201 \\ suspend {}
22022202 \\}
22032203 , &[_][]const u8{
22042204 "tmp.zig:3:12: error: expected type 'anyframe', found '*const @Frame(func)'",
......@@ -2231,10 +2231,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
22312231 \\ frame = async bar();
22322232 \\}
22332233 \\fn foo() void {
2234 \\ suspend;
2234 \\ suspend {}
22352235 \\}
22362236 \\fn bar() void {
2237 \\ suspend;
2237 \\ suspend {}
22382238 \\}
22392239 , &[_][]const u8{
22402240 "tmp.zig:3:13: error: expected type '*@Frame(bar)', found '*@Frame(foo)'",
......@@ -2269,7 +2269,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
22692269 \\ var result = await frame;
22702270 \\}
22712271 \\fn func() void {
2272 \\ suspend;
2272 \\ suspend {}
22732273 \\}
22742274 , &[_][]const u8{
22752275 "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
......@@ -2347,7 +2347,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
23472347 \\ bar();
23482348 \\}
23492349 \\fn bar() void {
2350 \\ suspend;
2350 \\ suspend {}
23512351 \\}
23522352 , &[_][]const u8{
23532353 "tmp.zig:1:1: error: function with calling convention 'C' cannot be async",
test/runtime_safety.zig+17-17
......@@ -13,7 +13,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
1313
1414 cases.addRuntimeSafety("switch on corrupted enum value",
1515 \\const std = @import("std");
16 ++ check_panic_msg ++
16 ++ check_panic_msg ++
1717 \\const E = enum(u32) {
1818 \\ X = 1,
1919 \\};
......@@ -28,7 +28,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2828
2929 cases.addRuntimeSafety("switch on corrupted union value",
3030 \\const std = @import("std");
31 ++ check_panic_msg ++
31 ++ check_panic_msg ++
3232 \\const U = union(enum(u32)) {
3333 \\ X: u8,
3434 \\};
......@@ -54,7 +54,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
5454
5555 cases.addRuntimeSafety("@tagName on corrupted enum value",
5656 \\const std = @import("std");
57 ++ check_panic_msg ++
57 ++ check_panic_msg ++
5858 \\const E = enum(u32) {
5959 \\ X = 1,
6060 \\};
......@@ -67,7 +67,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
6767
6868 cases.addRuntimeSafety("@tagName on corrupted union value",
6969 \\const std = @import("std");
70 ++ check_panic_msg ++
70 ++ check_panic_msg ++
7171 \\const U = union(enum(u32)) {
7272 \\ X: u8,
7373 \\};
......@@ -92,7 +92,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
9292
9393 cases.addRuntimeSafety("slicing operator with sentinel",
9494 \\const std = @import("std");
95 ++ check_panic_msg ++
95 ++ check_panic_msg ++
9696 \\pub fn main() void {
9797 \\ var buf = [4]u8{'a','b','c',0};
9898 \\ const slice = buf[0..4 :0];
......@@ -100,7 +100,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
100100 );
101101 cases.addRuntimeSafety("slicing operator with sentinel",
102102 \\const std = @import("std");
103 ++ check_panic_msg ++
103 ++ check_panic_msg ++
104104 \\pub fn main() void {
105105 \\ var buf = [4]u8{'a','b','c',0};
106106 \\ const slice = buf[0..:0];
......@@ -108,7 +108,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
108108 );
109109 cases.addRuntimeSafety("slicing operator with sentinel",
110110 \\const std = @import("std");
111 ++ check_panic_msg ++
111 ++ check_panic_msg ++
112112 \\pub fn main() void {
113113 \\ var buf_zero = [0]u8{};
114114 \\ const slice = buf_zero[0..0 :0];
......@@ -116,7 +116,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
116116 );
117117 cases.addRuntimeSafety("slicing operator with sentinel",
118118 \\const std = @import("std");
119 ++ check_panic_msg ++
119 ++ check_panic_msg ++
120120 \\pub fn main() void {
121121 \\ var buf_zero = [0]u8{};
122122 \\ const slice = buf_zero[0..:0];
......@@ -124,7 +124,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
124124 );
125125 cases.addRuntimeSafety("slicing operator with sentinel",
126126 \\const std = @import("std");
127 ++ check_panic_msg ++
127 ++ check_panic_msg ++
128128 \\pub fn main() void {
129129 \\ var buf_sentinel = [2:0]u8{'a','b'};
130130 \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0;
......@@ -133,7 +133,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
133133 );
134134 cases.addRuntimeSafety("slicing operator with sentinel",
135135 \\const std = @import("std");
136 ++ check_panic_msg ++
136 ++ check_panic_msg ++
137137 \\pub fn main() void {
138138 \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 };
139139 \\ const slice = buf_slice[0..3 :0];
......@@ -141,7 +141,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
141141 );
142142 cases.addRuntimeSafety("slicing operator with sentinel",
143143 \\const std = @import("std");
144 ++ check_panic_msg ++
144 ++ check_panic_msg ++
145145 \\pub fn main() void {
146146 \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 };
147147 \\ const slice = buf_slice[0.. :0];
......@@ -367,7 +367,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
367367 \\}
368368 \\fn add(a: i32, b: i32) i32 {
369369 \\ if (a > 100) {
370 \\ suspend;
370 \\ suspend {}
371371 \\ }
372372 \\ return a + b;
373373 \\}
......@@ -407,7 +407,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
407407 \\ var frame = @asyncCall(&bytes, {}, ptr, .{});
408408 \\}
409409 \\fn other() callconv(.Async) void {
410 \\ suspend;
410 \\ suspend {}
411411 \\}
412412 );
413413
......@@ -424,7 +424,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
424424 \\ await frame;
425425 \\}
426426 \\fn other() void {
427 \\ suspend;
427 \\ suspend {}
428428 \\}
429429 );
430430
......@@ -440,7 +440,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
440440 \\ other();
441441 \\}
442442 \\fn other() void {
443 \\ suspend;
443 \\ suspend {}
444444 \\}
445445 );
446446
......@@ -454,7 +454,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
454454 \\ resume p; //bad
455455 \\}
456456 \\fn suspendOnce() void {
457 \\ suspend;
457 \\ suspend {}
458458 \\}
459459 );
460460
......@@ -1019,7 +1019,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
10191019 \\}
10201020 \\
10211021 \\fn failing() anyerror!void {
1022 \\ suspend;
1022 \\ suspend {}
10231023 \\ return second();
10241024 \\}
10251025 \\
test/stage1/behavior/async_fn.zig+42-42
......@@ -18,9 +18,9 @@ test "simple coroutine suspend and resume" {
1818}
1919fn simpleAsyncFn() void {
2020 global_x += 1;
21 suspend;
21 suspend {}
2222 global_x += 1;
23 suspend;
23 suspend {}
2424 global_x += 1;
2525}
2626
......@@ -34,7 +34,7 @@ test "pass parameter to coroutine" {
3434}
3535fn simpleAsyncFnWithArg(delta: i32) void {
3636 global_y += delta;
37 suspend;
37 suspend {}
3838 global_y += delta;
3939}
4040
......@@ -50,7 +50,7 @@ test "suspend at end of function" {
5050
5151 fn suspendAtEnd() void {
5252 x += 1;
53 suspend;
53 suspend {}
5454 }
5555 };
5656 S.doTheTest();
......@@ -74,11 +74,11 @@ test "local variable in async function" {
7474
7575 fn add(a: i32, b: i32) void {
7676 var accum: i32 = 0;
77 suspend;
77 suspend {}
7878 accum += a;
79 suspend;
79 suspend {}
8080 accum += b;
81 suspend;
81 suspend {}
8282 x = accum;
8383 }
8484 };
......@@ -102,7 +102,7 @@ test "calling an inferred async function" {
102102 }
103103 fn other() void {
104104 other_frame = @frame();
105 suspend;
105 suspend {}
106106 x += 1;
107107 }
108108 };
......@@ -129,7 +129,7 @@ test "@frameSize" {
129129 }
130130 fn other(param: i32) void {
131131 var local: i32 = undefined;
132 suspend;
132 suspend {}
133133 }
134134 };
135135 S.doTheTest();
......@@ -269,7 +269,7 @@ test "async function with dot syntax" {
269269 var y: i32 = 1;
270270 fn foo() callconv(.Async) void {
271271 y += 1;
272 suspend;
272 suspend {}
273273 }
274274 };
275275 const p = async S.foo();
......@@ -298,7 +298,7 @@ fn doTheAwait(f: anyframe->void) void {
298298fn simpleAsyncFn2(y: *i32) callconv(.Async) void {
299299 defer y.* += 2;
300300 y.* += 1;
301 suspend;
301 suspend {}
302302}
303303
304304test "@asyncCall with return type" {
......@@ -312,7 +312,7 @@ test "@asyncCall with return type" {
312312
313313 fn afunc() i32 {
314314 global_frame = @frame();
315 suspend;
315 suspend {}
316316 return 1234;
317317 }
318318 };
......@@ -348,7 +348,7 @@ test "async fn with inferred error set" {
348348
349349 fn failing() !void {
350350 global_frame = @frame();
351 suspend;
351 suspend {}
352352 return error.Fail;
353353 }
354354 };
......@@ -375,7 +375,7 @@ fn nonFailing() (anyframe->anyerror!void) {
375375 return &Static.frame;
376376}
377377fn suspendThenFail() callconv(.Async) anyerror!void {
378 suspend;
378 suspend {}
379379 return error.Fail;
380380}
381381fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
......@@ -400,7 +400,7 @@ fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
400400 resume @frame();
401401 }
402402 my_result.* += 1;
403 suspend;
403 suspend {}
404404 my_result.* += 1;
405405}
406406
......@@ -421,7 +421,7 @@ test "heap allocated async function frame" {
421421
422422 fn someFunc() void {
423423 x += 1;
424 suspend;
424 suspend {}
425425 x += 1;
426426 }
427427 };
......@@ -454,7 +454,7 @@ test "async function call return value" {
454454
455455 fn other(x: i32, y: i32) Point {
456456 frame = @frame();
457 suspend;
457 suspend {}
458458 return Point{
459459 .x = x,
460460 .y = y,
......@@ -487,7 +487,7 @@ test "suspension points inside branching control flow" {
487487
488488 fn func(b: bool) void {
489489 while (b) {
490 suspend;
490 suspend {}
491491 result += 1;
492492 }
493493 }
......@@ -541,7 +541,7 @@ test "pass string literal to async function" {
541541
542542 fn hello(msg: []const u8) void {
543543 frame = @frame();
544 suspend;
544 suspend {}
545545 expectEqualStrings("hello", msg);
546546 ok = true;
547547 }
......@@ -566,7 +566,7 @@ test "await inside an errdefer" {
566566
567567 fn func() void {
568568 frame = @frame();
569 suspend;
569 suspend {}
570570 }
571571 };
572572 S.doTheTest();
......@@ -590,7 +590,7 @@ test "try in an async function with error union and non-zero-bit payload" {
590590
591591 fn theProblem() ![]u8 {
592592 frame = @frame();
593 suspend;
593 suspend {}
594594 const result = try other();
595595 return result;
596596 }
......@@ -622,7 +622,7 @@ test "returning a const error from async function" {
622622
623623 fn fetchUrl(unused: i32, url: []const u8) ![]u8 {
624624 frame = @frame();
625 suspend;
625 suspend {}
626626 ok = true;
627627 return error.OutOfMemory;
628628 }
......@@ -967,7 +967,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
967967
968968 fn failing() !void {
969969 global_frame = @frame();
970 suspend;
970 suspend {}
971971 return error.Fail;
972972 }
973973 };
......@@ -977,7 +977,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
977977test "@asyncCall with actual frame instead of byte buffer" {
978978 const S = struct {
979979 fn func() i32 {
980 suspend;
980 suspend {}
981981 return 1234;
982982 }
983983 };
......@@ -993,7 +993,7 @@ test "@asyncCall using the result location inside the frame" {
993993 fn simple2(y: *i32) callconv(.Async) i32 {
994994 defer y.* += 2;
995995 y.* += 1;
996 suspend;
996 suspend {}
997997 return 1234;
998998 }
999999 fn getAnswer(f: anyframe->i32, out: *i32) void {
......@@ -1095,7 +1095,7 @@ test "nosuspend function call" {
10951095 }
10961096 fn add(a: i32, b: i32) i32 {
10971097 if (a > 100) {
1098 suspend;
1098 suspend {}
10991099 }
11001100 return a + b;
11011101 }
......@@ -1170,7 +1170,7 @@ test "suspend in for loop" {
11701170 global_frame = @frame();
11711171 var sum: u32 = 0;
11721172 for (stuff) |x| {
1173 suspend;
1173 suspend {}
11741174 sum += x;
11751175 }
11761176 global_frame = null;
......@@ -1197,7 +1197,7 @@ test "suspend in while loop" {
11971197 global_frame = @frame();
11981198 defer global_frame = null;
11991199 while (stuff) |val| {
1200 suspend;
1200 suspend {}
12011201 return val;
12021202 }
12031203 return 0;
......@@ -1206,7 +1206,7 @@ test "suspend in while loop" {
12061206 global_frame = @frame();
12071207 defer global_frame = null;
12081208 while (stuff) |val| {
1209 suspend;
1209 suspend {}
12101210 return val;
12111211 } else |err| {
12121212 return 0;
......@@ -1339,7 +1339,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
13391339
13401340 fn bar(x: i32, args: anytype) anyerror!void {
13411341 global_frame = @frame();
1342 suspend;
1342 suspend {}
13431343 global_int = x;
13441344 }
13451345 };
......@@ -1361,7 +1361,7 @@ test "async function passed align(16) arg after align(8) arg" {
13611361 fn bar(x: u64, args: anytype) anyerror!void {
13621362 expect(x == 10);
13631363 global_frame = @frame();
1364 suspend;
1364 suspend {}
13651365 global_int = args[0];
13661366 }
13671367 };
......@@ -1383,7 +1383,7 @@ test "async function call resolves target fn frame, comptime func" {
13831383
13841384 fn bar() anyerror!void {
13851385 global_frame = @frame();
1386 suspend;
1386 suspend {}
13871387 global_int += 1;
13881388 }
13891389 };
......@@ -1406,7 +1406,7 @@ test "async function call resolves target fn frame, runtime func" {
14061406
14071407 fn bar() anyerror!void {
14081408 global_frame = @frame();
1409 suspend;
1409 suspend {}
14101410 global_int += 1;
14111411 }
14121412 };
......@@ -1430,7 +1430,7 @@ test "properly spill optional payload capture value" {
14301430
14311431 fn bar() void {
14321432 global_frame = @frame();
1433 suspend;
1433 suspend {}
14341434 global_int += 1;
14351435 }
14361436 };
......@@ -1466,13 +1466,13 @@ test "handle defer interfering with return value spill" {
14661466
14671467 fn bar() anyerror!void {
14681468 global_frame1 = @frame();
1469 suspend;
1469 suspend {}
14701470 return error.Bad;
14711471 }
14721472
14731473 fn baz() void {
14741474 global_frame2 = @frame();
1475 suspend;
1475 suspend {}
14761476 baz_happened = true;
14771477 }
14781478 };
......@@ -1497,7 +1497,7 @@ test "take address of temporary async frame" {
14971497
14981498 fn foo(arg: i32) i32 {
14991499 global_frame = @frame();
1500 suspend;
1500 suspend {}
15011501 return arg + 1234;
15021502 }
15031503
......@@ -1520,7 +1520,7 @@ test "nosuspend await" {
15201520
15211521 fn foo(want_suspend: bool) i32 {
15221522 if (want_suspend) {
1523 suspend;
1523 suspend {}
15241524 }
15251525 return 42;
15261526 }
......@@ -1569,11 +1569,11 @@ test "nosuspend on async function calls" {
15691569// };
15701570// const S1 = struct {
15711571// fn c() S0 {
1572// suspend;
1572// suspend {}
15731573// return S0{};
15741574// }
15751575// fn d() !S0 {
1576// suspend;
1576// suspend {}
15771577// return S0{};
15781578// }
15791579// };
......@@ -1591,11 +1591,11 @@ test "nosuspend resume async function calls" {
15911591 };
15921592 const S1 = struct {
15931593 fn c() S0 {
1594 suspend;
1594 suspend {}
15951595 return S0{};
15961596 }
15971597 fn d() !S0 {
1598 suspend;
1598 suspend {}
15991599 return S0{};
16001600 }
16011601 };