E06200: use of parenthesis '( )' not allowed in this context

Category: E06xxx Type hierarchy checks · Reported in phase: SYMBOL_DEFINITION · Classification: PARENTHESIS_NOT_REQUIRED · All error codes

What went wrong

You used parentheses '()' on a generic type in a context where you're declaring a TYPE, not creating an INSTANCE. In EK9, '()' means "construct". When specifying a type (declarations, inheritance, type parameters), omit '()'.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 681 (What is the correct syntax for generic type parameterizat...)

How to fix it

  1. Remove '()' from TYPE positions (declarations, extends, type params)
  2. Keep '()' only on OUTERMOST type when creating an instance
  3. Check nested generics - inner types never have '()'

See also

  • 'List of String' = the TYPE List parameterized with String
  • 'List() of String' = CREATE a new instance of List of String
  • E06200: '()' in type position (this error)
  • E06210: missing '()' in instantiation position

Common causes

  • Using List() in type position instead of List
  • Using GenericType() when extending/implementing
  • Adding '()' to inner generic types in nested generics

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E06200: use of parenthesis '( )' not allowed in this context

#!ek9
defines module error.e06200.bad

  defines function

    misplacedParentheses()
      //In a TYPE, no parentheses: the type is 'List of String'
      names as List() of String?

      //Only the outermost construction takes them: the inner type is a type
      nested <- List() of List() of String

Fixed: Parentheses construct, 'of' parameterises: List() of String, and a type is List of String

#!ek9
defines module error.e06200.good

  defines function

    wellPlacedParentheses()
      <- rtn as Integer?
      names as List of String: List()
      nested <- List() of List of String
      rtn: length names + length nested

Questions and answers

These Q&A entries show E06200 and its fix: