Few days ago I've created a bug (#3800), claiming that this should compile:
type
A[T] = object
B[T] = A
C = B[int]
Araq said it shouldn't, but I don't understand why. Is it possible to create typeclass aliases? The following example hints that it is:
type A[T] = object
type B = A
proc foo(b: B) = discard
var b: A[int]
foo(b)
Sure it's possible, but either you have [T] in both B and A or in neither:
type
A[T] = object
B = A
C = B[int]
type
A[T] = object
B[T] = A[T]
C = B[int]
I'm not convinced. A is a valid typeclass and I want to make a generic alias to it and the fact that I don't use generic parameter T shouldn't matter.
I can't make any coherent explanation of this behaviour.
To make my point clearer, these compile:
type A[T] = object
type C = int | float
type B[T] = C
proc foo(b: B) = discard
foo(5)
type A[T] = object
type C = A | int | float
type B = C
proc foo(b: B) = discard
foo(5)
And this doesn't:
type A[T] = object
type C = A | int | float
type B[T] = C
proc foo(b: B) = discard
foo(5)