-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
@tailrec false positive #21642
Comments
Found a way to minimize it further (I think this is the same bug): @tailrec def minimal9[A](count: Int, value: Either[Int, String]): A = {
value match {
case Left(n) if n > 0 => minimal9(count, Right(n.toString))
case Right(s) => minimal9(count - 1, Left(s.length))
case _ => minimal9(count, Left(0))
}
} Note that removing type parameter makes the issue go away. |
Even further minimized: @tailrec def minimal9_1[A](value: Option[Int]): A = {
value match {
case Some(n) if n > 0 => minimal9_1(Some(n + 1))
case _ => ???
}
} @tailrec def minimal9_2[A](value: Option[Int]): A = {
value match {
case Some(n) => minimal9_2(None)
case _ => ???
}
} |
I think this is a "false positive" because the test result says there is a problem. A health screening test that comes back negative is a good thing, unless it is a false negative. ("Dodgers optimistic for Freeman's playoff status as ankle X-rays negative".) Workaround is to use an explicit type arg (which is otherwise inferred to be Nothing):
Edit: or
IIUC it's not supposed to be necessary due to erasure: I don't know why the comment is the opposite of reality. |
Compiler version
3.5.0
Minimized code
EDIT: found a way to minimize the example:
Original snippet:
Output
on both evalSlow calls.
Expectation
Should work since they are in tail position, works in Scala 2.12.
The text was updated successfully, but these errors were encountered: