From 41f77d261ead2508acdd3bd3f88a5cbbcefff05f Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 27 Dec 2023 20:57:39 +0100 Subject: [PATCH] Better line information on effect violation We can capture the line info from the original future source and direct violation errors there --- chronos/internal/asyncfutures.nim | 96 ++++++++++++++++++------------- chronos/internal/asyncmacro.nim | 4 +- 2 files changed, 57 insertions(+), 43 deletions(-) diff --git a/chronos/internal/asyncfutures.nim b/chronos/internal/asyncfutures.nim index a7fd961..8078952 100644 --- a/chronos/internal/asyncfutures.nim +++ b/chronos/internal/asyncfutures.nim @@ -478,14 +478,26 @@ when chronosStackTrace: # newMsg.add "\n" & $entry error.msg = newMsg -proc internalCheckComplete*(fut: FutureBase) {.raises: [CatchableError].} = - # For internal use only. Used in asyncmacro - if not(isNil(fut.internalError)): - when chronosStackTrace: - injectStacktrace(fut.internalError) - raise fut.internalError +proc deepLineInfo(n: NimNode, p: LineInfo) = + n.setLineInfo(p) + for i in 0..