Seems that there's a bug in compiler while compiling code heavily using generics.
Look at the sample code: https://play.nim-lang.org/#ix=3z8L
The ambiguous call error message is in different compile cases is different. I've had the error message that there are conflicts in system.string and ConnectionStrInt, then the times.Duration and ConnectionStrBool, now system.bool and sha1.SecureHash. Orelse it might be that I'm doing something wrong.
Minimizing code before asking for question does really help when others try to solve your problem ... at least out pure pragmatism - debugging 124 lines is easier than 23, so more likely to get an answer
import std/[asyncdispatch, times, options, strutils, sha1]
type
Connection* = ref ConnectionObj
ConnectionObj* = object of RootObj
ConnectionRequest* = ref ConnectionRequestObj
ConnectionRequestObj* = object of RootObj
redis*: Connection
ConnectionStrBool* = distinct bool
ConnectionRequestT*[T] = ref object of ConnectionRequest
ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
keepttl: bool
proc execute*(req: ConnectionRequest): Future[bool] {.async.} = discard
proc execute*(req: ConnectionRequestT[bool]): Future[bool] {.async.} = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]): Future[bool] {.async.} = discard
proc testExecute() {.async.} =
var connection: COnnectionSetRequest
let repl = await connection.execute()
Achieved by randomly deleting code until you stop getting the error.
type
Connection* = ref ConnectionObj
ConnectionObj* = object of RootObj
ConnectionRequest* = ref ConnectionRequestObj
ConnectionRequestObj* = object of RootObj
ConnectionStrBool* = distinct bool
ConnectionRequestT*[T] = ref object of ConnectionRequest
ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
proc execute*(req: ConnectionRequestT[bool]) = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]) = discard
ConnectionSetRequest().execute()
type
ConnectionRequest* = ref object of RootObj
ConnectionStrBool* = distinct bool
ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
ConnectionRequestT*[T] = ref object of ConnectionRequest
proc execute*(req: ConnectionRequestT[bool]) = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]) = discard
ConnectionSetRequest().execute()
fails with /tmp/zzz.nim(4, 37) Error: inheritance only works with non-final objects; for ConnectionRequestT[zzz.ConnectionStrBool] to be inheritable it must be 'object of RootObj' instead of 'object', but swapping object declaration order into
type
ConnectionRequest* = ref object of RootObj
ConnectionStrBool* = distinct bool
ConnectionRequestT*[T] = ref object of ConnectionRequest
ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
proc execute*(req: ConnectionRequestT[bool]) = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]) = discard
ConnectionSetRequest().execute()
Gives the same error as your code /tmp/zzz.nim(9, 23) Error: ambiguous call; both zzz.execute(req: ConnectionRequestT[system.bool]) [declared in /tmp/zzz.nim(7, 6)] and zzz.execute(req: ConnectionRequestT[zzz.ConnectionStrBool]) [declared in /tmp/zzz.nim(8, 6)] match for: (ConnectionSetRequest)