summary refs log tree commit diff stats
path: root/tests/destructor/tgotoexc_leak.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2024-06-10 18:43:23 +0200
committerGitHub <noreply@github.com>2024-06-10 18:43:23 +0200
commit8cbbe12ee4eaa9568d246638b1f712a5a57e20ab (patch)
treec09be0ee71cd1058f1354f8821f75987dd92f5aa /tests/destructor/tgotoexc_leak.nim
parent1cbcbd9269e19838858a9b26d455590b753b85f8 (diff)
downloadNim-8cbbe12ee4eaa9568d246638b1f712a5a57e20ab.tar.gz
fixes #22398; [backport] (#23704)
Diffstat (limited to 'tests/destructor/tgotoexc_leak.nim')
-rw-r--r--tests/destructor/tgotoexc_leak.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/destructor/tgotoexc_leak.nim b/tests/destructor/tgotoexc_leak.nim
new file mode 100644
index 000000000..c8a234085
--- /dev/null
+++ b/tests/destructor/tgotoexc_leak.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''0
+true'''
+  cmd: "nim c --gc:arc $file"
+"""
+
+# bug #22398
+
+for i in 0 ..< 10_000:
+  try:
+    try:
+      raise newException(ValueError, "")
+    except CatchableError:
+      discard
+      raise newException(ValueError, "") # or raise getCurrentException(), just raise works ok
+  except ValueError:
+    discard
+echo getOccupiedMem()
+echo getCurrentException() == nil