summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-04-26 22:02:02 +0800
committerGitHub <noreply@github.com>2024-04-26 16:02:02 +0200
commit0b0f185bd1db2500079aefd888078b6bd1094270 (patch)
treef59c8a0145bc27e354924c176e1ae0a5aa9c36a2 /tests
parent407c0cb64a804e6f5ffa693ec0e79c9171393a29 (diff)
downloadNim-0b0f185bd1db2500079aefd888078b6bd1094270.tar.gz
fixes #23536; Stack trace with wrong line number when the proc called inside for loop (#23540)
fixes #23536
Diffstat (limited to 'tests')
-rw-r--r--tests/errmsgs/t23536.nim26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/errmsgs/t23536.nim b/tests/errmsgs/t23536.nim
new file mode 100644
index 000000000..610a85bab
--- /dev/null
+++ b/tests/errmsgs/t23536.nim
@@ -0,0 +1,26 @@
+discard """
+  matrix: "--stackTrace:on --excessiveStackTrace:off"
+"""
+
+const expected = """
+wrong trace:
+t23536.nim(22)           t23536
+t23536.nim(17)           foo
+assertions.nim(41)       failedAssertImpl
+assertions.nim(36)       raiseAssert
+fatal.nim(53)            sysFatal
+"""
+
+
+try:
+  proc foo = # bug #23536
+    doAssert false
+
+  for i in 0 .. 1:
+
+
+    foo()
+except AssertionDefect:
+  let e = getCurrentException()
+  let trace = e.getStackTrace
+  doAssert "wrong trace:\n" & trace == expected