summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-08-01 17:19:43 +0800
committerGitHub <noreply@github.com>2021-08-01 11:19:43 +0200
commit916d0c21af6153338a8064ff953b579ff87c6ba6 (patch)
tree8a1953628a6ef1f8e5af13a35b6c025827c38461
parent52e276c82daf2b8a33f4e4304eac3074bb37b70d (diff)
downloadNim-916d0c21af6153338a8064ff953b579ff87c6ba6.tar.gz
fix #18620 (#18624)
* fix #18620

* add testcase
-rw-r--r--lib/system/excpt.nim5
-rw-r--r--tests/exception/t18620.nim17
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
5' href='#n155'>155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195