E01085: suffix operator used in prefix position - place AFTER expression
What went wrong
You're using a SUFFIX operator in PREFIX position. SUFFIX operators must come AFTER the expression they operate on.
EK9's main suffix operator:
- ? (isSet) - checks if value is set/valid: value?
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 794 (Why does EK9 care about operator placement (prefix vs suf...)
Common causes
- Coming from languages with prefix null checks (isset(), is_null())
- Confusing with ternary operator syntax from other languages
- Pattern matching habits from functional languages
How to fix it
Move the ? operator to AFTER the expression:
- ?value --> value?
- ?object.property --> object.property?
See also
- E01084: Prefix operator used in suffix position
- https://ek9.io/operators.html
- https://ek9.io/basics.html#tri-state
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E01085: suffix operator used in prefix position - place AFTER expression
#!ek9 defines module error.e01085.bad defines function isKnown() -> name as String <- rtn as Boolean: ?name
Fixed: Put the suffix operator after the expression: name?
#!ek9 defines module error.e01085.good defines function isKnown() -> name as String <- rtn as Boolean: name?
Questions and answers
These Q&A entries show E01085 and its fix:
Found a problem?
If EK9 reported E01085 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.