E09010: inappropriate use in this context

Category: E09xxx Plugin resolution · Reported in phase: FULL_RESOLUTION · Classification: INAPPROPRIATE_USE · All error codes

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'). 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

  1. Check EK9 documentation for valid contexts
  2. Move construct to appropriate location
  3. Use alternative syntax for this context

Common causes

  • Leaving the '()' off a constructor call, so the type name is used as a value
  • 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: