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 18:37:25 -0800
committerGitHub <noreply@github.com>2019-01-08 18:37:25 -0800
commit6ce3949c8aa489d268f272829d03edab175bfc7a (patch)
tree777513c9aef3896204b8dfd9cea40517d57d2ce7 /tests/errmsgs
parentbf3a308e86e7c5999855546962aed564218a8121 (diff)
downloadNim-6ce3949c8aa489d268f272829d03edab175bfc7a.tar.gz
add `isNamedTuple`; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) which leaked implementation detail (#10070)
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of leaking implementation detail (Field0: 1, Field1: 2)
  fixes this: #8670 (comment) /cc @alehander42 @Vindaar @mratsim

* Note: isNamedTuple is useful in other places, eg #10010 (comment)

* move isNamedTuple to helpers.nim to avoid exposing new symbol to system.nim

* remove workaround in tests/vm/tissues.nim failing test now that #10218 was makes it work
Diffstat (limited to 'tests/errmsgs')
-rw-r--r--tests/errmsgs/tnested_generic_instantiation.nim6
-rw-r--r--tests/errmsgs/tnested_generic_instantiation2.nim27
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/errmsgs/tnested_generic_instantiation.nim b/tests/errmsgs/tnested_generic_instantiation.nim
index 6aea7cbcc..77353605c 100644
--- a/tests/errmsgs/tnested_generic_instantiation.nim
+++ b/tests/errmsgs/tnested_generic_instantiation.nim
@@ -17,3 +17,9 @@ converter toWrapped[T](value: T): Wrapped[T] =
 
 let result = Plain()
 discard $result
+
+proc foo[T2](a: Wrapped[T2]) =
+  # Error: generic instantiation too nested
+  discard $a
+
+foo(result)
diff --git a/tests/errmsgs/tnested_generic_instantiation2.nim b/tests/errmsgs/tnested_generic_instantiation2.nim
new file mode 100644
index 000000000..d9bba15b0
--- /dev/null
+++ b/tests/errmsgs/tnested_generic_instantiation2.nim
@@ -0,0 +1,27 @@
+discard """
+errormsg: "generic instantiation too nested"
+"""
+
+#[
+bug #4766
+see also: tnested_generic_instantiation.nim
+]#
+
+proc toString*[T](x: T) =
+  for name, value in fieldPairs(x):
+    when compiles(toString(value)):
+      discard
+    toString(value)
+
+type
+  Plain = ref object
+    discard
+
+  Wrapped[T] = object
+    value: T
+
+converter toWrapped[T](value: T): Wrapped[T] =
+  Wrapped[T](value: value)
+
+let result = Plain()
+toString(result)