Hi, the following code does not compile :
type
A[T] = object
x: T
B[X] = object
when X is A:
y: int
var b = B[A[int]]()
The compiler produces the message:
.nim(10, 10) Error: cannot instantiate: 'A'
How could I test that the generic param X is an instance of the generic class A, without instantiating it?I found half of a solution, this code works:
type
A[T] = object
x: T
B[X] = object
when X is A[any]:
z: int
var b = B[A[int]]()
echo b.z
But when adding a second generic parameter to A, it does not work anymore: the code compiles, but X is not matched with A:
type
A[T,U] = object
x: T
y: U
B[X] = object
when X is A[any,any]:
z: int
var b = B[A[int,float]]()
echo b.z
produces:
.nim(10, 7) Error: undeclared field: 'z'