summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-02-11 01:14:57 +0200
committerZahary Karadjov <zahary@gmail.com>2014-02-11 01:14:57 +0200
commita158053ae9d04ebd882b2c973ddf4a3dd7d4efe8 (patch)
treee0603a6329810239e51587546e0ba6a59a1f484f /tests
parente8c87d070a4fa507208a042e9f02b356eaa567ad (diff)
downloadNim-a158053ae9d04ebd882b2c973ddf4a3dd7d4efe8.tar.gz
fixes #797; generic procs can be used in places expecting matching concrete proc types
Diffstat (limited to 'tests')
-rw-r--r--tests/generics/tinferredgenericprocs.nim20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/generics/tinferredgenericprocs.nim b/tests/generics/tinferredgenericprocs.nim
new file mode 100644
index 000000000..ac445fd32
--- /dev/null
+++ b/tests/generics/tinferredgenericprocs.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''123
+1
+2
+3'''
+"""
+
+# https://github.com/Araq/Nimrod/issues/797
+proc foo[T](s:T):string = $s
+
+type IntStringProc = proc(x: int): string 
+
+var f1 = IntStringProc(foo)
+var f2: proc(x: int): string = foo
+var f3: IntStringProc = foo
+
+echo f1(1), f2(2), f3(3)
+
+for x in map([1,2,3], foo): echo x
+