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"