-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Incorrect code ends up passing the typechecker due to GADT logic misfiring #9274
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
Comments
[log typer] ==> adapting cats.implicits.catsSyntaxPartialOrder[F[B]](lhs:F[B])(ord) to ?{ <= : [applied to (tolerance:B) returning ?] }
?
adapt to subtype cats.syntax.PartialOrderOps[F[B]] !<:< ?{ <= : [applied to (tolerance:B) returning ?] }
approx F(param)1, from below = false, bound = [_$1] =>> Any, inst = [_$1] =>> Any
approx B(param)1, from below = false, bound = Any, inst = Any
[log typer] <== adapting cats.implicits.catsSyntaxPartialOrder[F[B]](lhs:F[B])(ord) to ?{ <= : [applied to (tolerance:B) returning ?] }
= cats.implicits.catsSyntaxPartialOrder[F[B]](lhs:F[B])(ord):
cats.syntax.PartialOrderOps[Any] This is very weird, we have a value of type |
This is somehow caused by the GADT logic, if I comment out the following lines: https://github.com/lampepfl/dotty/blob/8a4c442acd67591c672a80d0fd865fbc5cc110c5/compiler/src/dotty/tools/dotc/typer/Typer.scala#L3377-L3397 I don't know how to reproduce this without cats either, but it's not too difficult to try out from the dotty repo:
|
What I gather is happening:
|
@smarter I've been suspecting that I cut a bit too many shortcuts when writing |
Oh, and before I forget to write this here for clarity/posterity: adding type parameters of every function we see to Corrections to the above welcome. |
Minimized code
This could probably be minimized further.
Cats 2.1.1 compiled for Scala 2.13.
Output
Compiles and results in a
ClassCastException
.Expectation
Shouldn't compile. The ascriptions aren't necessary to trigger the bug, I just included them for clarity.
This may be specific to the Scala 2 unpickler. I wasn't able to reproduce it with this pure-Dotty minimization:
The above fails to compile, as I would expect.
The text was updated successfully, but these errors were encountered: