-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Typer failure in local recursive union types #15158
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
We need a minimization that does not depend on scalatest |
@nicolasstucki I've managed to minimize it to not require scalatest, seems that issue is present due to the bug in inlining. I've updated the snippet in the issue description |
Minimized: //> using scala "3.2.0-RC1-bin-20220429-400427d-NIGHTLY"
// //> using scala "3.1.2" // Last stable working version
inline def foo(testFun: Any): Unit = {}
val x = foo {
type Rec[A] = A match
case String => Option[Rec[String]]
val arr = new collection.mutable.ArrayBuffer[Rec[String]](8)
} assertion failed: no owner from <none>/ <none> in new collection.mutable.ArrayBuffer[Option[Option[Rec[String]]]] |
It looks like the clue here is that we have a recursive match type which will never get reduced and it's defined in a non-inline block passed to an inline method. But I'm still wondering why this doesn't break if I replace |
it also breaks with |
The issue started in bf937ed. |
My guess is that the constructor of the collection has to be overloaded for it to break.
Can you confirm this? It does not look at all related to by-name parameter handling. |
Can confirm that bisection points to bf937ed as the first bad commmit. A reproducer without stdlib: class Opt[T]
class Buf[A](elts: Any, sz: Int):
def this(n: Int) = this(???, n)
inline def foo(testFun: Any): Unit = {}
val x = foo {
type Rec[A] = A match
case String => Opt[Rec[String]]
val arr = new Buf[Rec[String]](8)
} |
@griggt Thanks, that's good to know! I found a way to avoid the failure but am still unsure what the root cause is, and whether we should not just reject the code. |
Compiler version
3.2.0-RC1-bin-20220429-400427d-NIGHTLY
Works with 3.1.2
First bad commit bf937ed in #14295
Minimized code
Output (click arrow to expand)
Short error message:
The text was updated successfully, but these errors were encountered: