summary refs log tree commit diff stats
path: root/tests/run
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/trettypeinference.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/run/trettypeinference.nim b/tests/run/trettypeinference.nim
new file mode 100644
index 000000000..eea5b597d
--- /dev/null
+++ b/tests/run/trettypeinference.nim
@@ -0,0 +1,29 @@
+discard """
+  msg:    "instantiated for string\ninstantiated for int\ninstantiated for bool"
+  output: "int\nseq[string]\nA\nB\n100\ntrue"
+"""
+
+import typetraits
+
+proc plus(a, b): auto = a + b
+
+proc `+`(a, b: string): seq[string] = @[a, b]
+
+var i = plus(10, 20)
+var s = plus("A", "B")
+
+echo i.type.name
+echo s.type.name
+
+proc inst(a): auto =
+  static: echo "instantiated for ", a.type.name
+  result = a
+
+echo inst("A")
+echo inst("B")
+echo inst(100)
+echo inst(true)
+
+# XXX: [string, tyGenericParam] is cached instead of [string, string]
+# echo inst[string, string]("C")
+