-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The ?
operator from stew/results
doesn't work in async procs
#37
Comments
?
from stew/results
doesn't work in async functions?
operator from stew/results
doesn't work in async procs
can this be fixed on the async side? there's a few things in chronos that would benefit from Result support, for example to mark with type that things have gone from future to present - I also imagine it would make sense to extend |
Can i get simple reproducible source to check |
I've been hitting this too. Here's a simple snippet: proc resultTest(): Result[int, cstring] =
ok(1)
proc asyncResultTest(): Future[Result[void, cstring]] {.async.} =
let val = ? resultTest()
await sleepAsync(1.seconds)
return ok() It would also be nice if we could do |
@kdeme I'm not a fan of |
Also i think its impossible to fix in |
The async pragma is currently intercepting all return statements in the body of the async function in order to replace them with an operation that completes the returned
Future
.The problem is that return statements appearing in expanded templates (such as
?
) are not detected by this mechanism and this leads to compilation errors.A possible solution would be to use a template called
returnStatement(val)
instead ofreturn
in?
. Theasync
pragma will insert a local override for this template within the body of the async proc that will do the right thing.The text was updated successfully, but these errors were encountered: