* fix #18620

* add testcase
This commit is contained in:
flywind
2021-08-01 17:19:43 +08:00
committed by GitHub
parent 52e276c82d
commit 916d0c21af
2 changed files with 18 additions and 4 deletions

View File

@@ -524,10 +524,7 @@ proc getStackTrace(e: ref Exception): string =
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
## Returns the attached stack trace to the exception `e` as
## a `seq`. This is not yet available for the JS backend.
when not defined(nimSeqsV2):
shallowCopy(result, e.trace)
else:
result = move(e.trace)
shallowCopy(result, e.trace)
proc getStackTraceEntries*(): seq[StackTraceEntry] =
## Returns the stack trace entries for the current stack trace.

View File

@@ -0,0 +1,17 @@
discard """
matrix: "--gc:arc; --gc:refc"
"""
proc hello() =
raise newException(ValueError, "You are wrong")
var flag = false
try:
hello()
except ValueError as e:
flag = true
doAssert len(getStackTraceEntries(e)) > 0
doAssert len(getStackTraceEntries(e)) > 0
doAssert flag