From 6266c68ab6e4eaf247132dd867e055fa733675df Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 21 Jan 2018 21:08:51 +0100 Subject: [PATCH] writeStackTrace now officially has no IO effect anymore for more convenient debugging --- changelog.md | 3 +++ lib/system.nim | 5 +++-- lib/system/excpt.nim | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index bce2bcca34..f7a656937c 100644 --- a/changelog.md +++ b/changelog.md @@ -220,3 +220,6 @@ styledEcho "Red on Green.", resetStyle - If you use ``--dynlibOverride:ssl`` with OpenSSL 1.0.x, you now have to define ``openssl10`` symbol (``-d:openssl10``). By default OpenSSL 1.1.x is assumed. + +- ``writeStackTrace`` is now proclaimed to have no IO effect (even though it does) + so that it is more useful for debugging purposes. diff --git a/lib/system.nim b/lib/system.nim index 8f83fb8c38..2c0617e4d5 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3211,9 +3211,10 @@ when not defined(JS): #and not defined(nimscript): ## allows you to override the behaviour of your application when CTRL+C ## is pressed. Only one such hook is supported. - proc writeStackTrace*() {.tags: [WriteIOEffect], gcsafe.} + proc writeStackTrace*() {.tags: [], gcsafe.} ## writes the current stack trace to ``stderr``. This is only works - ## for debug builds. + ## for debug builds. Since it's usually used for debugging, this + ## is proclaimed to have no IO effect! when hostOS != "standalone": proc getStackTrace*(): string {.gcsafe.} ## gets the current stack trace. This only works for debug builds. diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 8e42ea4683..0087c61395 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -386,9 +386,9 @@ proc writeStackTrace() = when hasSomeStackTrace: var s = "" rawWriteStackTrace(s) - showErrorMessage(s) + cast[proc (s: string) {.noSideEffect, tags: [], nimcall.}](showErrorMessage)(s) else: - showErrorMessage("No stack traceback available\n") + cast[proc (s: string) {.noSideEffect, tags: [], nimcall.}](showErrorMessage)("No stack traceback available\n") proc getStackTrace(): string = when hasSomeStackTrace: