E06200: use of parenthesis '( )' not allowed in this context
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
- Remove '()' from TYPE positions (declarations, extends, type params)
- Keep '()' only on OUTERMOST type when creating an instance
- Check nested generics - inner types never have '()'
See also
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:
Found a problem?
If EK9 reported E06200 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.