E4155

E4155#

Cycle in a const or type alias declaration.

Constants and type aliases can refer to other declarations in the same package, but the references must not form a cycle.

Erroneous example#

///|
const A : Int = B + 1

///|
const B : Int = A + 1

///|
type T1 = T2

///|
type T2 = T1

Suggestion#

Break the cycle so that every constant and type alias eventually resolves to a concrete value or type.

///|
const A : Int = 1

///|
const B : Int = A + 1

///|
type T1 = Int

///|
type T2 = T1

///|
fn use_declarations(value : T2) -> Int {
  value + B
}

///|
test {
  assert_eq(use_declarations(A), 3)
}