fixes #797; generic procs can be used in places expecting matching concrete proc types
This commit is contained in:
parent
e8c87d070a
commit
a158053ae9
5 changed files with 80 additions and 29 deletions
20
tests/generics/tinferredgenericprocs.nim
Normal file
20
tests/generics/tinferredgenericprocs.nim
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue