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
Type mismatch where 'found' and 'required' coincide. #6522
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6522?orig=1 |
@paulp said: |
@paulp said:
The required type is an existential with a clause involving candidateUpperObject, and the found isn't. |
Scott Morrison (scott) said: Shouldn't both the types here (required and found) be the path dependent type |
@paulp said: |
Scott Morrison (scott) said: trait Z {
trait Lower
trait Upper {
val result: Z
def inverse: result.Lower
}
def upperObject: Upper
def lowerPredicate: Lower => Boolean
def thisOneWorks = {
val upper = upperObject
val predicate = upper.result.lowerPredicate
predicate(upper.inverse)
}
def butThisOneDoesnt = {
for (
upper <- Seq(upperObject);
predicate = upper.result.lowerPredicate
) yield predicate(upper.inverse)
}
} The error is now type mismatch;
found : upper.result.Lower
required: upper.result.Lower where val upper: Z.this.Upper on the |
@paulp said (edited on Oct 18, 2012 3:16:44 AM UTC): trait Z {
trait Lower
trait Upper {
val result: Z
def inverse: result.Lower
}
val upper: Upper
val pred: Lower => Unit
def ok1 = Seq(upper) map { u => u.result.pred(u.inverse) }
def ok2 = Seq(upper) map { u => u.result.pred match { case p => p(u.inverse) } }
def ok3 = Seq(upper) map { u => u.inverse match { case x => u.result.pred(x) } }
def ok4 = Seq(upper) map { u => (u.result.pred, u.inverse) match { case (p, x) => p(x) } }
def ok5 = Seq(upper) map { u => (u.result.pred, u ) match { case (p, u1: u.type) => p(u1.inverse) } }
def nok = Seq(upper) map { u => (u.result.pred, u ) match { case (p, u1) => p(u1.inverse) } }
/**
a.scala:15: error: type mismatch;
found : u1.result.Lower
required: u.result.Lower
def nok = Seq(upper) map { u => (u.result.pred, u) match { case (p, u1) => p(u1.inverse) } }
^
**/
} |
@paulp said: |
Scott Morrison (scott) said: |
Scala 3.3.1-RC1-bin-20230403-b0ad1e1-NIGHTLY:
|
The following code produces
I tried adding -uniqid and -explaintypes, and then get
which doesn't add much to my understanding.
Here's the code; I'm sure it can be reduced slightly.
I'm reporting this as a bug on the presumption that when the types shown in after 'found' and 'required' print the same, it's at least a problem with error reporting, if not an actual type checker bug.
The text was updated successfully, but these errors were encountered: