E07890: not mutable
What went wrong
You're attempting to modify an IMMUTABLE value. Once set, immutable values cannot be changed.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 141 (How does EK9 protect constants from mutation?)
- ek9 -q 143 (How do EK9 constants compare to const, final, and static ...)
- ek9 -q 140 (How do I define constants in EK9?)
- ek9 -q 142 (How do I use constants across modules in EK9?)
How to fix it
- Use mutable variable if modification needed
- Create new value instead of modifying
- Remove mutation attempt
Common causes
- Trying to reassign const
- Mutation operation on immutable value
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07890: not mutable
#!ek9 defines module error.e07890.bad defines constant NAME <- "STEVE" START_DATE <- 2023-11-03 defines function changeConstants() //A constant never changes START_DATE += P2D NAME: "Stephen"
Fixed: Copy the constant into a variable, and change that
#!ek9 defines module error.e07890.good defines constant NAME <- "STEVE" START_DATE <- 2023-11-03 defines function nextWeek() <- rtn as Date: START_DATE //A variable, copied from the constant, can change rtn += P1W fullName() <- rtn as String: NAME + " Limb"
Questions and answers
These Q&A entries show E07890 and its fix:
Found a problem?
If EK9 reported E07890 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.