E1142: assignment to a constant

View source

A const is fixed at compile time.

A const is fixed at compile time. It is a value, not a binding, so no assignment, compound assignment, field assignment or indexed assignment may name it. ADR-0052 defines constants as immutable values that do not take part in ownership. The compiler reports this error instead of an undeclared identifier, because the name does exist.

Example

actus
const LIMIT: Int = 10;

verb main() {
    LIMIT = 20;
}

Fix

Declare an erg binding for a value that changes, and assign to that.

actus
verb main() {
    erg limit: Int = 10;
    limit = 20;
}

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