-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unreducible app of HK type when nesting dependent func + match types #9999
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
This would need more info to determine whether it's really a bug or whether the reported error is a true one. |
I'll be happy to provide more info --- just let me know what I can do :-) I am very keen on understanding whether this issue is a real bug, and whether it can be fixed --- because were it solved, it would be possible to represent a form of session types in Dotty. |
@odersky here is another (simpler) example that highlights the issue. case class A();
case class B();
type M2[X <: A|B] = X match {
case A => A
case B => B
}
def f2(x: A|B): M2[x.type] = x match {
case _: A => A()
case _: B => B()
}
// This definition of type M1 works: function f1() below compiles
/*
type M1[X <: A|B] = X match {
case A => A
case B => (x: A|B) => x.type match { // Should be equivalent to M2[x.type]
case A => A
case B => B
}
}
*/
// This definition of type M1 causes an error when f1() below is compiled:
// "unreducible application of higher-kinded type M2"
type M1[X <: A|B] = X match {
case A => A
case B => (x: A|B) => M2[x.type]
}
def f1(x: A|B): M1[x.type] = x match {
case _: A => A()
case _: B => (x: A|B) => f2(x)
} The code above does not compile:
However, if M2[x.type] is manually expanded and inlined in M1 (as in the commented-out version of M1 above), then no errors are reported. |
Although I have been following this bug for 6 months now, I deeply regret I didn't post earlier.
Any one of these are sufficiently serious bugs, that I had expected that it would be dealt with in a week or two as a high priority bug. Six months later, without any obvious progress, I am becoming concerned this this bug has not received the attention it deserves. A) Can the bug status tag be restored. C) What further information (if any) is required? Firstly this is a definitely a bug. Thanks |
I thought I would make one further comment regarding priority. This is the type of bug that passes unit testing of atomic features, but is exposed when those features are composed into a larger application. As soon as more people develop larger applications with Scala3, I expect there will be far more complaints about this bug. |
Attention is a finite resource: over the last month alone, about 150 new issues were created and the same number of issues (both old and new) were closed, so it's inevitable that things slip through, especially if they're not straight-forward. So yes, if you think an issue is important it's not a bad idea to leave a comment explaining why to raise awareness about it. |
If `M[_]` is a match type alias, it was rejected for being an unreducible application of wildcard types. It is now accepted. I believe that is sound - this is siply an unreducible match type. The situation is not the same as `F[_]` where `F` is an abstract type that can be refined in several ways in subclasses. Fixes scala#9999
If `M[_]` is a match type alias, it was rejected for being an unreducible application of wildcard types. It is now accepted. I believe that is sound - this is siply an unreducible match type. The situation is not the same as `F[_]` where `F` is an abstract type that can be refined in several ways in subclasses. Fixes scala#9999
Thanks for the detailed reports. I believe I was able to fix this. |
If `M[_]` is a match type alias, it was rejected for being an unreducible application of wildcard types. It is now accepted. I believe that is sound - this is siply an unreducible match type. The situation is not the same as `F[_]` where `F` is an abstract type that can be refined in several ways in subclasses. Fixes scala#9999
If `M[_]` is a match type alias, it was rejected for being an unreducible application of wildcard types. It is now accepted. I believe that is sound - this is siply an unreducible match type. The situation is not the same as `F[_]` where `F` is an abstract type that can be refined in several ways in subclasses. Fixes scala#9999
Minimized code
Output
Expectation
Type-checking should succeed.
Notes
The error arises whenever I try to nest 2+ levels of dependent function types + match types
Indeed, if
fun2()
is commented out, then the type-checking offun1()
succeedsThe whole code above appears to type-check correctly when using VS Code with the Dotty extension:
Fun(fun1)
withNop()
infun2()
, the resulting error message correctly reports the expected typefun1()
is inlined infun2()
, its type is correctly inferred and type-checking succeedsThe error is reported by the
PostTyper
compiler phase, which is not executed by the Dotty extension for VS CodeThe text was updated successfully, but these errors were encountered: