-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Match Type with no cases should not reduce to ErrorType
#19953
Conversation
|
I added this test because at least one library depended on it. I'm not sure which one off the top of my head, although I could probably dig it up. Anyway, that means we probably need to find a way to bring it back into the green. |
Accepting that the resulting unsoundness is bad and needs fixing, I would consider reintroducing throwing exceptions to be throwing (ironically) the baby out with the bath water (👶🏼 💙 ). Is it not possible to spot how this is isn't being properly propagated in type select and in however its impacting spotted-leopards? |
I've tried that approach in #19961 but I suspect we are missing other problematic cases. |
This reverts commit 9ae1598 Note that the changes in Typer: ``` val unsimplifiedType = result.tpe simplify(result, pt, locked) result.tpe.stripTypeVar match case e: ErrorType if !unsimplifiedType.isErroneous => errorTree(xtree, e.msg, xtree.srcPos) case _ => result ``` cannot be reverted yet since the MatchReducer now also reduces to an `ErrorType` for MatchTypeLegacyPatterns, introduced after 9ae1598.
i18488.scala was only passing because of the bug in the MatchReducer, as we can see in the subtyping trace: ``` ==> isSubType TableQuery[BaseCrudRepository.this.EntityTable] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]]? ==> isSubType Query[BaseCrudRepository.this.EntityTable, Extract[BaseCrudRepository.this.EntityTable]] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]] (left is approximated)? ==> isSubType E[Option] <:< Extract[BaseCrudRepository.this.EntityTable]? ==> isSubType [T[_$1]] =>> Any <:< Extract? ==> isSubType Any <:< Extract[T]? ==> isSubType Any <:< T match { case AbstractTable[t] => t } <: t (right is approximated)? ==> isSubType Any <:< <error Match type reduction failed since selector T matches none of the cases case AbstractTable[t] => t> (right is approximated)? <== isSubType Any <:< <error Match type reduction failed since selector T matches none of the cases case AbstractTable[t] => t> (right is approximated) = true <== isSubType Any <:< T match { case AbstractTable[t] => t } <: t (right is approximated) = true <== isSubType Any <:< Extract[T] = true <== isSubType [T[_$1]] =>> Any <:< Extract = true ... <== isSubType Extract[BaseCrudRepository.this.EntityTable] <:< E[Option] = true <== isSubType Query[BaseCrudRepository.this.EntityTable, Extract[BaseCrudRepository.this.EntityTable]] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]] (left is approximated) = true <== isSubType TableQuery[BaseCrudRepository.this.EntityTable] <:< Query[BaseCrudRepository.this.EntityTable, E[Option]] = true ```
8a32741
to
be4065e
Compare
When match type reduction fails because none of the cases match,
the
MatchReducer
reduces to anErrorType
, it does neither of:TypeError
exception, orNoType
which the TypeComparer (among many) would interpret as not reducing.Since
ErrorType extends FlexType
, the returned result of the reduction will conform to anything.Fixes #19949
Fixes #19950