Closed Menduist closed 11 months ago
funny enough, this PR should also improve performance because we will no longer generate a temporary variable that must be zero:ed then copied to the future
This branch is failing on nimbus:
/home/tavon/Status/nimbus-eth2/beacon_chain/el/el_manager.nim(724, 18) template/generic instantiation of `err` from here
/home/tavon/Status/nimbus-eth2/beacon_chain/el/el_manager.nim(717, 42) Error: cannot instantiate Future [type declared in /home/tavon/Status/nimbus-eth2/vendor/nim-chronos/chronos/futures.nim(68, 3)]
got: <T>
but expected: <T>
Some generic fun to fix
EDIT: caused by https://github.com/nim-lang/Nim/issues/22645
this should have a test that shows the previously broken code snippet
We found a failure with this PR, and no workaround yet:
proc testReturner: Future[int] {.async.} =
template returner =
result = 5
returner
I'll look a bit more for a workaround, otherwise the solution will be to retain the temporary result
variable.
Superseded by #449
The idea of this PR would be that the closure never completes the future, instead just writes to the internalValue, and the
futureContinue
would take care of completing the future (for now I've just applied this to thereturn
rewrite, but could be used everywhere) Besides fixing #415, it could also avoid a copy to the internalValue once the future is finishedHowever, might have some downsides