Skip to content

Commit

Permalink
Ensure "noreturn" callbacks work for asyncAwait. Fixes #299.
Browse files Browse the repository at this point in the history
Just adds a matching unit test.
  • Loading branch information
s-ludwig committed Aug 2, 2024
1 parent bfab44b commit dfa6bc1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/vibe/internal/async.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,13 @@ private template hasAnyScopeParameter(Callback) {
static if (SC.length == 0) enum hasAnyScopeParameter = false;
else enum hasAnyScopeParameter = any!(c => c & ParameterStorageClass.scope_)([SC]);
}

static if (is(noreturn)) // issue 299, requires newer host compilers
version (unittest) {
alias CB = noreturn delegate(int) @safe nothrow;
alias wait = delegate noreturn(_) => assert(0);
alias cancel = delegate noreturn(_, x) => assert(0);
alias done = delegate noreturn(_) => assert(0);
alias w = Waitable!(CB, wait, cancel, done);
static assert (__traits(compiles, { asyncAwaitAny!(false, w); }));
}

0 comments on commit dfa6bc1

Please sign in to comment.