Skip to content
Playground(another site)

bynk.resolve.const_cycle

Error Constants refer to each other in a cycle, so none of them has a value.

Constants may refer to each other in any order, across files and through uses, but a value cannot depend on itself: in a cycle no member has anything to start from. The error lists the cycle (First → Second → First) and is reported once, at the member declared first. Break the cycle by giving one member a literal or other static value. A reference such as Second is itself a static initialiser, so this is the only rule that limits constants naming each other; bynk.resolve.bad_const_initialiser covers initialisers that are not static at all.

Example

const First: Int = Second // ✗ `First` → `Second` → `First`
const Second: Int = First
const Second: Int = 10 // ✓ end the chain at a literal

In the Book

See also

  • The grammar rule it governs: const_decl.
  • Every code in its category, Resolution, on the diagnostic index.
  • bynk explain bynk.resolve.const_cycle shows the same from the installed toolchain, without a network.