If I have the following:
type Foo[T] = object
proc foo1*[T, U](f: Foo[T], op: proc (t: T): U ): void =
discard
then calling foo1 is no problem:
let f = Foo[int]()
proc inc1(x: int): int = x + 1
foo1(f, inc1) # Works :)
but if I add typedesc to the type parameters, then things go south:
proc foo2*[T: typedesc, U: typedesc](f: Foo[T], op: proc (t: T): U ): void =
discard
foo2(f, inc1) # Error: type mismatch: got (Foo[system.int], proc (x: int): int
# but expected one of:
# proc foo2[T: typedesc; U: typedesc](f: Foo[T]; op: proc (t: T): U): void
Does this look like a bug?
(Compilable gist @ https://play.nim-lang.org/?gist=dd6c80defbe40d028ba90f1acf41925f)
It doesn't look like a bug.
Firstly your generic T is not consistent when you call foo2. f and incl are not valid parameters for foo2.
Also my understanding is that typedesc is a special type and not an object type.
So I don't think you can do the following because the object constructor needs an object type:
type Foo[T] = object
let f2 = Foo[typedesc]()
Not sure what your use case is but maybe checkout this: