-
Notifications
You must be signed in to change notification settings - Fork 51
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
Complete futures in closure finally (fix #415) #449
Conversation
lgtm but needs a round of testing with nimbus-eth2 |
Defects are now handled by failing the future with a new exception, similarly to other exceptions |
let's leave the future running and propagate to |
This is causing some regression in the libp2p CI, investigating.. |
Fixed the regression, I also took the opportunity to "improve" #401, since we now need a template to set the result anyway The issue was: proc returnResult: Future[int] {.async.} =
var result: int
result = 12
return result was not working properly anymore, since The fix is: var result {.used.}: int
template setResult(code: untyped) {.used.} =
result = code
block:
var result: int
result = 12
setResult(12) since result is bound in the template, this will set the correct result. And I took the opportunity to handle the implicit returns directly inside setResult: template setResult(code: untyped) {.used.} =
when typeof(code) is void:
code
else:
result = code LMKWYT |
libp2p & nimbus tests now pass with this branch |
Alternative to #418
Fixes #415
This moves the error handling to the closure (instead of the
futureContinue
). In the finally, we complete withresult
in case of success. Example: