-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Leaking SelectionProto in GADT casts for implicit conversions #15867
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
Note that trying this out on the latest nightly the compiler actually crashes:
|
If an exception is throwing while compiling no file during no phase, does it make a noise? 🤔 |
One would hope that |
note that the problem reproduces with enum Sub[A, B]:
case Refl[S]() extends Sub[S, S]
class Pow:
def meth = ???
given fromInt[Dummy]: Conversion[Int, Pow] = ???
def foo[T](t: T, ev: Sub[T, Int]) =
ev match
case Sub.Refl() =>
t.meth (Dale doubts it's interestingly more minimal that way, but perhaps it's worth noting regardless — it helped my understanding.) |
We began by investigating why the enriched crash report is missing so much information. Dale was able to fix it, and that fix will be its own PR, separate from the actual GADT issue. |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
main
branchMinimized code
Output
Expectation
Both
foo
andbar
should compile.In the two functions of this example we are trying to cast
t: T
toPow
implicitly, whereT
is constrained to be a subtype ofList[Int]
andInt
respectively. We could use the conversionfromList
andfromInt
based on the GADT bounds.The reason of the error in
foo
is that we leak theSelectionProto
type in the GADT cast for the implicit conversion instance which shadows the real type of the instance. Specifically, the typed tree offoo
looks like:Here we look for a implicit conversion of expected type
Conversion[(t : T), ?{ ** : ? }]
with aSelectionProto
in it, and theSelectionProto
gets leaked in the GADT cast, shadowing the real type of the conversion instance.Note that the
SelectionProto
also leaks inbar
, the typed tree of which is:As seen in it,
bar
works because the conversion instance fromInt
toPow
is a stable pathfromInt
, causing the typer to include its identity and GADT bounds in the cast.The text was updated successfully, but these errors were encountered: