diff options
author | Zahary Karadjov <zahary@gmail.com> | 2012-09-29 16:49:04 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2012-10-03 01:59:49 +0300 |
commit | 7e44015491d4002be3c80cb7d6797e4c63651fbe (patch) | |
tree | 6650bd361de96a9e70b75c089bf7c4521e755d9a /tests/run | |
parent | b28fcdfa93ccf132b878e7dcd26e36d48f107212 (diff) | |
download | Nim-7e44015491d4002be3c80cb7d6797e4c63651fbe.tar.gz |
implemented return type inference
Other fixes: * bind once is now the default for type classes as documented in the manual * fixes an issue in template overloading (erroneous ambiguity when different typedesc params were used)
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/trettypeinference.nim | 29 |
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") + |