You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objectTest {
enumBase {
caseCase1caseCase2
}
enumInvariant[T] {
caseInv(t: T)
}
defunsound[T](t: T):T=Inv(t) match {
caseInv(_: Base) =>// here we still shouldn't know anything about TCase1// but instead, we have a bound T === Base, which is bogus
}
valnotCase2:Case2.type= unsound(Case2) // == Case1
}
There are probably many variations on the above - for example, T could be used in another function argument as well.
The issue appears to be caused by Dotty inferring GADT bounds based on pattern types - it decides that:
T in Invariant[T] is GADT-valid
type of Inv(_: Base) pattern is Invariant[Base]
and then based on an Invariant[T] <: Inv[Base] check it infers that T === Base.
A possible fix might be to assign better types to patterns - Inv(_: Base) can match values of Inv[T] type, not Inv[Base].
Another avenue might be noticing that from the pattern matching we should know only that:
$scrutinee.type <: Inv[T]
$scrutinee.t.type <: Base
The text was updated successfully, but these errors were encountered:
Right, it was supposed to be Base. For clarity, there are two nested patterns - Inv(_), and _: Base - one matches on $scrutinee and the other on $scrutinee.t.
There are probably many variations on the above - for example,
T
could be used in another function argument as well.The issue appears to be caused by Dotty inferring GADT bounds based on pattern types - it decides that:
T
inInvariant[T]
is GADT-validInv(_: Base)
pattern isInvariant[Base]
and then based on an
Invariant[T] <: Inv[Base]
check it infers thatT === Base
.A possible fix might be to assign better types to patterns -
Inv(_: Base)
can match values ofInv[T]
type, notInv[Base]
.Another avenue might be noticing that from the pattern matching we should know only that:
$scrutinee.type <: Inv[T]
$scrutinee.t.type <: Base
The text was updated successfully, but these errors were encountered: