E09010: inappropriate use in this context
What went wrong
You're using a language construct in a context where it's not valid. The usual case is a TYPE NAME where a value is needed: 'Greeter' instead of 'Greeter()', or a call or operator applied to the type itself ('C1 <> c1'). An enumeration type is no different: 'CardSuit' alone is the type, never one of its values - name a value ('CardSuit.Hearts') or make an unset one ('CardSuit()'). The type stands alone only as the source of 'for x in CardSuit' and 'cat CardSuit'. A dynamic function or class declared where no function or type encloses it is the same error.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 952 (Why must EK9 constructs be used in their valid context...)
How to fix it
- Check EK9 documentation for valid contexts
- Move construct to appropriate location
- Use alternative syntax for this context
Common causes
- Leaving the '()' off a constructor call, so the type name is used as a value
- An enumeration type ('CardSuit') where a value ('CardSuit.Hearts') is meant
- Calling a method or operator on the type rather than on an instance
- A dynamic function or class outside any function, method or type
See also
- E09010: construct not valid in context (this error)
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E09010: inappropriate use in this context
#!ek9 defines module error.e09010.bad defines class Greeter greet() <- rtn as String: "Hello" defines function makeGreeter() <- rtn as Greeter: Greeter
Fixed: Construct an instance - a type name alone is not a value
#!ek9 defines module error.e09010.good defines class Greeter greet() <- rtn as String: "Hello" defines function makeGreeter() <- rtn as Greeter: Greeter()
Questions and answers
These Q&A entries show E09010 and its fix:
Found a problem?
If EK9 reported E09010 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.