Closed nitely closed 3 months ago
workaround:
type Callback = proc(s: string): int
proc foobar(s: string): int =
result = s.len
proc foo[B](b:B) =
echo b("foo")
proc bar[B](a: seq[B]) =
for x in items a:
echo x("foo")
proc main() =
foo[Callback](foobar)
bar(@[foobar])
bar[Callback](@[foobar.Callback])
main()
mmh pretty sure this is an inference limitation that won't get fixed.
Not really inference as much as Callback
gets noSideEffect
the following is "more correct"
type Callback = proc(s: string): int {.nimcall.} # or {.closure.}`
Description
Nim Version
Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2024-06-20 Copyright (c) 2006-2024 by Andreas Rumpf
git hash: 646bd99d461469f08e656f92ae278d6695b35778 active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information
I found it while trying to make a table of
[string, proc]
type with initial data.