-
Notifications
You must be signed in to change notification settings - Fork 1.1k
b: a.type but a.A != b.A #6635
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
To reiterate on what Paolo said, while I still understand it: the problem lies in the fact that if If we don't know that either of |
Thinking about this again, I see two algorithms. The fragile approach is trying to "undo" reduction, or catch the type before it's reduced, is unlikely to work — don't know if you could use GADT bounds for that, but @AleksanderBG would know. What might work better: notice that e1 and e2 are aliases, and use that to reduce For performance, we should not have to explore all accessible paths: typechecking should be incomplete. That resembles subtyping relations introduced by abstract types: if Suppose I declare somewhere a path Hence, for performance, Dotty should likely not recognize eagerly that But if I write |
BTW, https://doi.org/10.1145/3241653.3241657 describes in detail something similar to what I propose. They don't use union-find, but their data structure (path environments, a partition of paths, represented as a set of sets) gives the |
1. backtrack in more cases when we we fail after dealiasing 2. fall back to atoms comparisons when comparing two singleton types The widened criterion for (1) is still provisional. We need to come up with a criterion that is sound and has a low risk of leading to combinatorial explosion when comparing two long alias chains.
1. backtrack in more cases when we we fail after dealiasing 2. fall back to atoms comparisons when comparing two singleton types The widened criterion for (1) is still provisional. We need to come up with a criterion that is sound and has a low risk of leading to combinatorial explosion when comparing two long alias chains.
@Blaisorblade Nice diagnostics! See #8443 for a proposed fix. |
Fix #6635: Improve subtype tests for aliases and singleton types
Even if e2: e1.type, e1.A = e2.A can still fail, in the same way, in Scala and Dotty — as of Dotty 0.16.0-bin-20190606-c46553a-NIGHTLY:
https://gist.github.com/Blaisorblade/3e5a1102c0699f05f1c11333d785a077
See
castTestFail*
. We need in facte2: e1.type & something
, but even then the problem doesn't always appear.Part of the problem is triggered
e2.A
is aliased, because thene.A
can be evaluated too eagerly; it seems Dotty tries to correct for that, but not robustly enough.Errors
The text was updated successfully, but these errors were encountered: