`asyncfutures.nim`: proc addCallback*[T](future: Future[T], cb: proc (future: Future[T]) {.closure, gcsafe.}) = ## Adds the callbacks proc to be called when the future completes. ## ## If future has already completed then `cb` will be called immediately. future.addCallback( proc() = cb(future) ) proc `callback=`*(future: FutureBase, cb: proc () {.closure, gcsafe.}) = ## Clears the list of callbacks and sets the callback proc to be called when the future completes. ## ## If future has already completed then `cb` will be called immediately. ## ## It's recommended to use `addCallback` or `then` instead. future.clearCallbacks future.addCallback cb Run
Is one offender as the variant `cb: proc (future: Future[T])` is mapped to the _worse_ version that lacks the `future` parameter and thus creates an unnecessary closure. This is one source of the cycles IIRC and it's relatively easy to fix, the compiler's error messages will guide you. It might break compat but then so be it, it's worth it. We can at least offer some switch to keep code working.