diff options
author | flywind <xzsflywind@gmail.com> | 2021-08-01 17:19:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-01 11:19:43 +0200 |
commit | 916d0c21af6153338a8064ff953b579ff87c6ba6 (patch) | |
tree | 8a1953628a6ef1f8e5af13a35b6c025827c38461 | |
parent | 52e276c82daf2b8a33f4e4304eac3074bb37b70d (diff) | |
download | Nim-916d0c21af6153338a8064ff953b579ff87c6ba6.tar.gz |
fix #18620 (#18624)
* fix #18620 * add testcase
-rw-r--r-- | lib/system/excpt.nim | 5 | ||||
-rw-r--r-- | tests/exception/t18620.nim | 17 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 9f65db2fe..4814b77b4 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -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. diff --git a/tests/exception/t18620.nim b/tests/exception/t18620.nim new file mode 100644 index 000000000..ee23f8bac --- /dev/null +++ b/tests/exception/t18620.nim @@ -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 |