E07720: additional name only required for QUERY, HEADER or PATH parameters
What went wrong
A service parameter gives a wire name to a source that takes none. QUERY and HEADER need the name of the query parameter or header to read (':=: QUERY "q"'), and PATH may have one; REQUEST (the whole request) and CONTENT (the body) are not looked up by name, so ':=: REQUEST "body"' is this error.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1325 (Why does EK9 reject a qualifier name on a REQUEST or C...)
How to fix it
- Remove the name qualifier
- Only QUERY and HEADER need a name (PATH may have one)
The [EXAMPLE] section below shows ':=: REQUEST "body"', and the same parameter as ':=: REQUEST' with no name.
Common causes
- Adding qualifier to REQUEST parameter
- Unnecessary qualifier on certain types
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07720: additional name only required for QUERY, HEADER or PATH parameters
#!ek9 defines module error.e07720.bad defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open whole() as POST for :/ -> //The whole request has no name request as HTTPRequest :=: REQUEST "body" <- response as HTTPResponse: TextResponse($request)
Fixed: Remove the name from REQUEST, CONTENT and CONTEXT
#!ek9 defines module error.e07720.good defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open whole() as POST for :/ -> request as HTTPRequest :=: REQUEST <- response as HTTPResponse: TextResponse($request)
Questions and answers
These Q&A entries show E07720 and its fix:
Found a problem?
If EK9 reported E07720 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.