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: Give each if and while a condition that can change, instead of a Boolean literal
#!ek9 defines module error.e07390.good.fix defines function parenthesised() -> amount as Integer <- rtn as Integer: amount if amount? rtn: 1 while rtn < amount rtn++ negatedOrNested() -> amount as Integer <- rtn as Integer: amount if not amount? rtn: 1 while (rtn > amount) 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:
Found a problem?
If EK9 reported E07390 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.