summary refs log tree commit diff stats
path: root/tests/generics/tconstraints.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generics/tconstraints.nim')
-rw-r--r--tests/generics/tconstraints.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/generics/tconstraints.nim b/tests/generics/tconstraints.nim
new file mode 100644
index 000000000..3ca01cfd5
--- /dev/null
+++ b/tests/generics/tconstraints.nim
@@ -0,0 +1,16 @@
+discard """
+  errormsg: "type mismatch: got <int literal(232)>"
+  line: 16
+"""
+
+proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string =
+  result = $x
+
+type
+  TMyObj = tuple[x, y: int]
+
+var
+  x: TMyObj
+
+assert myGenericProc(x) == "(x: 0, y: 0)"
+assert myGenericProc(232) == "232"