E08083: arithmetic expression always produces a constant result
What went wrong
This arithmetic expression always produces the same constant result regardless of input.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 818 (Why does EK9 reject self-cancelling arithmetic?)
How to fix it
- Check variable names for typos (did you mean a different variable?)
- Replace with the constant value directly if intentional
- Use different variables for meaningful arithmetic
Common causes
- Typo (wrong variable name on one side)
- Copy-paste error
- Leftover debugging code
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E08083: arithmetic expression always produces a constant result
#!ek9 defines module error.e08083.bad defines function checkSubtractSelf() -> amount as Integer <- result as Integer? result: amount - amount checkDivideSelf() -> amount as Integer <- result as Integer? result: amount / amount checkModSelf() -> amount as Integer <- result as Integer? result: amount mod amount checkRemSelf() -> amount as Integer <- result as Integer? result: amount rem amount checkModOne() -> amount as Integer <- result as Integer? result: amount mod 1 checkRemOne() -> amount as Integer <- result as Integer? result: amount rem 1
Fixed: Arithmetic whose result depends on its operands
#!ek9 defines module error.e08083.good defines function addSelf() -> amount as Integer <- result as Integer? result: amount + amount multiplySelf() -> amount as Integer <- result as Integer? result: amount * amount subtractDifferent() -> first as Integer second as Integer <- result as Integer? result: first - second modTwo() -> amount as Integer <- result as Integer? result: amount mod 2 divideByTwo() -> amount as Integer <- result as Integer? result: amount / 2
Questions and answers
These Q&A entries show E08083 and its fix: