Skip to content

Recursive match type fails to compile #8449

Closed
@weihsiu

Description

@weihsiu

dotty version: 0.22.0-RC1
I've also tried dotty nightly but it also failed as well.

minimized code

type Fib[N <: Int] <: Int = N match {
  case 0 => 0
  case 1 => 1
  case _ => Fib[Fib[N - 1] + Fib[N - 2]]
}
val fib0: Fib[0] = 0
val fib1: Fib[1] = 1
val fib2: Fib[2] = 1
val fib3: Fib[3] = 2 // fails to compile

Compilation output

[error] 21 |  val fib3: Fib[3] = 2
[error]    |                     ^
[error]    |                     Found:    (2 : Int)
[error]    |                     Required: (1 : Int)
[error] one error found

expectation

compiles successfully

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions