E1118: constant depends on itself

View source

The value of a constant is computed at compile time from literals and from other constants.

The value of a constant is computed at compile time from literals and from other constants. If constant FIRST needs SECOND, and SECOND needs FIRST, no value can be computed. The compiler detects the cycle and reports it at one constant of the cycle (ADR-0052, ADR-0062). A constant that names itself is a cycle of length one.

Example

actus
const FIRST: u8 = SECOND;
const SECOND: u8 = FIRST;

verb main() {
}

Fix

Break the cycle: give at least one constant of it a value that does not name the others.

actus
const SECOND: u8 = 4u8;
const FIRST: u8 = SECOND;

verb main() {
}

Run actus explain E1118 in your terminal to read this entry offline. Browse Modules & rules or all error codes.