From 310b73b556957228c805df321d7a8c03d9bd2061 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Wed, 22 Mar 2017 07:06:05 +0700 Subject: [PATCH] Reduce the scope of stackTrace var (#5583) Fixes #5571. --- lib/pure/unittest.nim | 3 +-- tests/stdlib/tunittest.nim | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 563968960..1ea7b8545 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -375,7 +375,6 @@ template test*(name, body) {.dirty.} = ensureFormattersInitialized() if shouldRun(name): - var stackTrace {.inject.}: string checkpoints = @[] var testStatusIMPL {.inject.} = OK @@ -391,7 +390,7 @@ template test*(name, body) {.dirty.} = except: when not defined(js): checkpoint("Unhandled exception: " & getCurrentExceptionMsg()) - stackTrace = getCurrentException().getStackTrace() + var stackTrace {.inject.} = getCurrentException().getStackTrace() fail() finally: diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim index 3f8601323..674ce50dd 100644 --- a/tests/stdlib/tunittest.nim +++ b/tests/stdlib/tunittest.nim @@ -96,5 +96,12 @@ suite "bug #4494": check: allIt(0..3, tags[it] != tags[it + 1]) +suite "bug #5571": + test "can define gcsafe procs within tests": + proc doTest {.gcsafe.} = + let line = "a" + check: line == "a" + doTest() + static: echo "compile end"