-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Type parameters via intersection types crash the compiler #2858
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
Thanks for the report! The syntax you want is probably: val c: Cont[_] { type A = Int } = new Cont(1) But of course we shouldn't crash when you use an intersection. |
Thanks for the answer. Are these not supposed to be equivalent, though? Is there a formal specification of the ways in which they diverge? |
In theory I'd expect them to be equivalent yeah, in practice though, who knows ¯\_(ツ)_/¯ |
Fix #2858: Handle intersection selection when symbol only exists on one side
Here is one that still makes the compiler crash: val c: { type A; val x: A } & { type A = Int } = new Cont(1) Also, why does the following not type check?
EDIT: I guess that one is because of this change in Dotty, so it seems legit. |
Yeah, structural types are pretty different in Dotty and probably need more work. Could you open an issue for the crash you got? |
Some documentation on structural types: http://dotty.epfl.ch/docs/reference/changed/structural-types.html |
Sure, but why not reopen this one? AFAICT this is another manifestation of the same problem (assertion failure with |
No, it's pretty different since it only affects structural types, and it happens much later in the compiler pipeline (during erasure and not typechecking) |
Ok. I was confused by the output message |
Apparently the syntax
class Cont[type A]
has been removed. So I wrote this:It fails to compile with "
found: c.A0(c.x); required: Int
".So I tried this:
But the compiler crashes with:
The text was updated successfully, but these errors were encountered: