I'm having trouble upgrading my old code that worked under v0.13. The following snippet no longer works under v0.14.2.
type
G[N:static[int]] = object
v: int
A = G[1]
B = G[2]
static:
echo(A is B)
proc p(x:A) = echo "A:",x.v
proc p(x:B) = echo "B:",x.v
p(A(v:1))
p(B(v:2))
A and B used to be different types, but under v0.14, A is B. Is it an intended behavior or a regression?
Edit: It's not related to static types. Any generic type uses unused type parameter no longer creates a distinct type.
With an extra indirection, the following code compiles and runs fine
type
G[N:static[int]] = object
v: int
A = G[1]
B = G[2]
type
F[U] = object
v: U
X = F[A]
Y = F[B]
static:
echo(A is B)
echo(X is Y)
proc p(x:X) = echo "X:",x.v.v
proc p(x:Y) = echo "Y:",x.v.v
p(X(v:A(v:1)))
p(Y(v:B(v:2)))
This means that A is B while F[A] isnot F[B]. It's inconsistent and confusing. Should F[A] is F[B] if A is B? Or should A isnot B in the first place, since 1 isnot 2.