Open itspomf opened 1 month ago
It should be tagged nimcall
, it doesn't capture anything and nimcall
is convertible to closure
. It errors even when you tag the nested closure as closure
. It doesn't have to be a nested closure either:
import tables
proc keepIf2[A, B]( t: var Table[A, B], c: proc( v: B ): bool {.closure.} ): Table[A, B] =
discard
proc foo(sub: var Table[ char, Table[ char, int]]) =
discard sub.keepIf2 do (v: int) -> bool {.closure.}: # <-- compile-time error here
v mod 2 != 0
Are you sure this should compile? It seems like the signature of the closure should be (v: Table[char, int]) -> bool
instead. If so, maybe the error message could be improved to show the bound generic parameters?
Description
When calling a proc which expects a closure, it is not possible to nest a secondary closure within it, as illustrated in case 2 below.
When doing so, the compiler raises an error regarding a calling convention mismatch, warning that it got the
{.nimcall.}
pragma as opposed to{.closure.}
.Nim Version
Nim 2.0.8
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response