summary refs log tree commit diff stats
path: root/tests/errmsgs
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-01-08 15:58:47 -0800
committerGitHub <noreply@github.com>2019-01-08 15:58:47 -0800
commitbf3a308e86e7c5999855546962aed564218a8121 (patch)
treeb161eaf15c10cbef4bec95f5c7de278ccb0f118a /tests/errmsgs
parentfb26b95f815b5426e0a8aad98ca0ff018ef1f4db (diff)
downloadNim-bf3a308e86e7c5999855546962aed564218a8121.tar.gz
[error messages, stacktraces] fix #8794 #9270 #9767 #9768 (#9766)
* fixes #8794 : `Error: undeclared field: 'foo'` should show type (+ where type is defined) (hard to guess in generic code)

* fixes #9270: `--listFullPaths` not honored by `declared in foo.nim` messages

* fixes #9767: VM stacktrace doesn't honor --excessiveStackTrace:on

* fixes #9768: VM stacktrace misses column info, can lead to ambiguous or harder to read stacktraces

* refactors some col+1 code to col + ColOffset (self documents code)

* make getProcHeader show declared info location also for types and all routine kinds (including macros,templates) instead of just (rather arbitrarily) for iterator,proc,func,method

* --listFullPaths now is honored in more places

* fix typo system/except.nim => lib/system/excpt.nim

* remove substr(foo, 0) hack in compiler/vm.nim which seems old and not applicable anymore
Diffstat (limited to 'tests/errmsgs')
-rw-r--r--tests/errmsgs/m8794.nim2
-rw-r--r--tests/errmsgs/t8794.nim39
-rw-r--r--tests/errmsgs/t9768.nim30
3 files changed, 71 insertions, 0 deletions
diff --git a/tests/errmsgs/m8794.nim b/tests/errmsgs/m8794.nim
new file mode 100644
index 000000000..12e61cf54
--- /dev/null
+++ b/tests/errmsgs/m8794.nim
@@ -0,0 +1,2 @@
+type Foo3* = object
+  a1: int
diff --git a/tests/errmsgs/t8794.nim b/tests/errmsgs/t8794.nim
new file mode 100644
index 000000000..7f16a42fe
--- /dev/null
+++ b/tests/errmsgs/t8794.nim
@@ -0,0 +1,39 @@
+discard """
+  cmd: "nim check $options $file"
+  errormsg: ""
+  nimout: '''
+t8794.nim(39, 27) Error: undeclared field: 'a3' for type m8794.Foo3[declared in m8794.nim(1, 6)]
+'''
+"""
+
+
+
+
+
+
+
+
+
+
+
+
+## line 20
+
+## issue #8794
+
+import m8794
+
+when false: # pending https://github.com/nim-lang/Nim/pull/10091 add this
+  type Foo = object
+    a1: int
+
+  discard Foo().a2
+
+type Foo3b = Foo3
+var x2: Foo3b
+
+proc getFun[T](): T =
+  var a: T
+  a
+
+discard getFun[type(x2)]().a3
diff --git a/tests/errmsgs/t9768.nim b/tests/errmsgs/t9768.nim
new file mode 100644
index 000000000..18588c87c
--- /dev/null
+++ b/tests/errmsgs/t9768.nim
@@ -0,0 +1,30 @@
+discard """
+  errmsg: "unhandled exception:"
+  file: "system.nim"
+  nimout: '''
+stack trace: (most recent call last)
+t9768.nim(28, 33)        main
+t9768.nim(23, 11)        foo1
+'''
+"""
+
+
+
+
+
+
+
+
+
+
+## line 20
+
+proc foo1(a: int): auto =
+  doAssert a < 4
+  result = a * 2
+
+proc main()=
+  static:
+    if foo1(1) > 0: discard foo1(foo1(2))
+
+main()