summary refs log tree commit diff stats
path: root/tests/errmsgs/tnested_generic_instantiation2.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errmsgs/tnested_generic_instantiation2.nim')
-rw-r--r--tests/errmsgs/tnested_generic_instantiation2.nim27
1 files changed, 27 insertions, 0 deletions
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)