Skip to content

Type.simplified stops before reaching a fix point #12278

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions