I've been using meta-programming to create a sequence of tuples of procs at 
compile time, usable at run-time, but am having difficulty now with 0.16.0 
release.

This is a minimal example working with 0.14.2; my actual code has a macro to 
create something like ptest() and proc_list:
    
    
    proc ptest(pid: int): bool {.procvar.} =
      echo "foo",$pid
      return if pid == 100: true else: false
    
    var proc_list = newSeq[tuple[id:int; myproc:proc (pid:int):bool{.gcsafe, 
locks: 0.}]]()
    proc_list.add((0,ptest))
    proc_list.add((0,ptest))
    proc_list.add((0,ptest))
    
    echo (proc_list[0][1](100),"\n")
    echo (proc_list[1][1](200),"\n")
    echo (proc_list[2][1](300))
    

The error: 
    
    
    Error: type mismatch: got (seq[tuple[id: int, myproc: proc (pid: int): 
bool{.closure, gcsafe, locks: 0.}]], (int, proc (pid: int): bool{.gcsafe, 
locks: 0.}))
    but expected one of:
    proc add[T](x: var seq[T]; y: T)
    proc add(result: var string; x: float)
    proc add(x: var string; y: string)
    proc add(x: var string; y: cstring)
    proc add(x: var string; y: char)
    proc add(result: var string; x: int64)
    proc add[T](x: var seq[T]; y: openArray[T])
    

Can anybody help me so I don't pull all my hair out? It could be something 
simple I'm missing. I tried starting the pragma with "{.closure" but that 
didn't help. 

Reply via email to