Skip to content

Type.simplified stops before reaching a fix point #12278

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

Closed
OlivierBlanvillain opened this issue Apr 29, 2021 · 0 comments
Closed

Type.simplified stops before reaching a fix point #12278

OlivierBlanvillain opened this issue Apr 29, 2021 · 0 comments

Comments

@OlivierBlanvillain
Copy link
Contributor

This variation of tests/pos/i8449.scala:

import scala.compiletime.ops.int.*

object Test {
  type Fib[N <: Int] <: Int = N match {
    case 0 => 0
    case 1 => 1
    case Any => Fib[N - 1] + Fib[N - 2]
  }
  val fib2: Fib[2] = 1
}

Fails with:

-- [E007] Type Mismatch Error: tests/pos/i8449.scala:10:21 ---------------------
10 |  val fib2: Fib[2] = 1
   |                     ^
   |Found:    (1 : Int)
   |Required: Test.Fib[(2 : Int) - (1 : Int)] + Test.Fib[(2 : Int) - (2 : Int)]

I think the bug comes from Types.simplified which simplifies "one step" instead of reaching a fixed point.

OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2021
OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2021
@odersky odersky closed this as completed in 24e89fa May 1, 2021
odersky added a commit that referenced this issue May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant