From c206d2bc191712e4e5f89ecd87df7ef014bbb484 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Thu, 25 Mar 2021 14:20:26 +0100 Subject: [PATCH] Add raises annotation to withTimeout callbacks (#168) --- chronos/asyncloop.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chronos/asyncloop.nim b/chronos/asyncloop.nim index 4e5a483..3ae42d4 100644 --- a/chronos/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -951,7 +951,9 @@ proc withTimeout*[T](fut: Future[T], timeout: Duration): Future[bool] = var timer: TimerCallback var cancelling = false - proc continuation(udata: pointer) {.gcsafe.} = + # TODO: raises annotation shouldn't be needed, but likely similar issue as + # https://github.com/nim-lang/Nim/issues/17369 + proc continuation(udata: pointer) {.gcsafe, raises: [Defect].} = if not(retFuture.finished()): if not(cancelling): if not(fut.finished()): @@ -967,7 +969,9 @@ proc withTimeout*[T](fut: Future[T], timeout: Duration): Future[bool] = else: retFuture.complete(false) - proc cancellation(udata: pointer) {.gcsafe.} = + # TODO: raises annotation shouldn't be needed, but likely similar issue as + # https://github.com/nim-lang/Nim/issues/17369 + proc cancellation(udata: pointer) {.gcsafe, raises: [Defect].} = if not isNil(timer): clearTimer(timer) if not(fut.finished()):