From 7d63a1b54d2e1ab8fdd0bdbb95d3c84147ccf46f Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 28 Mar 2019 00:56:17 +0200 Subject: [PATCH] Fix wait() to allow Future[void]. --- chronos/asyncloop.nim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chronos/asyncloop.nim b/chronos/asyncloop.nim index 3beb766..6befa34 100644 --- a/chronos/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -768,7 +768,10 @@ proc wait*[T](fut: Future[T], timeout = InfiniteDuration): Future[T] = if fut.failed: retFuture.fail(fut.error) else: - retFuture.complete(fut.read()) + when T is void: + retFuture.complete() + else: + retFuture.complete(fut.read()) if timeout.isInfinite(): retFuture = fut elif timeout.isZero(): @@ -776,7 +779,10 @@ proc wait*[T](fut: Future[T], timeout = InfiniteDuration): Future[T] = if fut.failed: retFuture.fail(fut.error) else: - retFuture.complete(fut.read()) + when T is void: + retFuture.complete() + else: + retFuture.complete(fut.read()) else: retFuture.fail(newException(AsyncTimeoutError, "")) else: