I tried to get a proc as field in my client object, so i can swap it at runtime without having if else everywhere.
I have these definitions: proc sendProcU(nntp: NNTP | AsyncNNTP, data: string) {.multisync.} = await nntp.sock.send(data) NNTPClientBase*[SocketType] = ref object ... sendProc*: proc(nntp: NNTP | AsyncNNTP, data: string) NNTP* = NNTPClientBase[Socket] AsyncNNTP* = NNTPClientBase[AsyncSocket] proc new(T: typedesc[NNTP | AsyncNNTP], host: string, port: Port, tlsPort = port, user, pass: string, tls: bool): T = result = T(host: host, port: port, tlsPort: tlsPort, user: user, pass: pass) when T is NNTP: result.sock = newSocket() result.sendProc = (proc (nntp: NNTP, data: string))sendProcU else: result.sock = newAsyncSocket() result.sendProc = (proc (nntp: AsyncNNTP, data: string))sendProcU Run This results in the error: ` Error: generic instantiation too nested` at the last line where the sendProc field is assigned. Any idea what I am doing wrong and how to fix it ?