E07390: constant Boolean literal in expression is pointless
What went wrong
You have a constant Boolean value (like true or false) in a condition, making it pointless.
Worked examples
Compilable examples demonstrating this error and the correct fix:
How to fix it
- Remove condition if always true - just call directly
- Remove dead code if always false
- Use actual conditional logic
Common causes
- Debug code left in: if true ...
- A literal as the control of a ternary: 'true <- first else second' always yields 'first'
- Copy/paste error
- Incomplete refactoring
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07390: constant Boolean literal in expression is pointless
#!ek9 defines module error.e07390.bad defines function parenthesised() -> amount as Integer <- rtn as Integer: amount if (false) rtn: 1 while (true) rtn++ negatedOrNested() -> amount as Integer <- rtn as Integer: amount if not false rtn: 1 while ((false)) rtn++
Fixed: Use a condition that can change
#!ek9 defines module error.e07390.good defines function countDown() -> amount as Integer <- rtn as Integer: amount //A condition that can be either true or false while rtn > 0 rtn--
Questions and answers
These Q&A entries show E07390 and its fix: