-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.
Milestone
Description
const std = @import("std");
const assert = std.debug.assert;
var await_a_promise: promise = undefined;
var await_final_result: i32 = 0;
test "coroutine await" {
const p = async<std.debug.global_allocator> await_amain() catch unreachable;
resume p;
}
async fn await_amain() void {
const p = async await_another() catch unreachable;
const result = await p;
assert(result == 1234);
}
async fn await_another() i32 {
suspend |p| {
await_a_promise = p;
}
return 1234;
}
Here the assertion fails because the resume
causes the await
to complete improperly. The await should complete only after await_another
returns.
Zig should have a runtime safety assertion when you resume
a coroutine which is suspended in the await
state.
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.