E07450: function must have no parameters

Category: E07xxx Full resolution · Reported in phase: FULL_RESOLUTION · Classification: FUNCTION_MUST_HAVE_NO_PARAMETERS · All error codes

What went wrong

A function that should have NO parameters has parameters defined.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 812 (What are common stream pipeline errors in EK9?)

How to fix it

  1. Remove parameters from function definition
  2. Or use appropriate function type with parameters

Common causes

  • Wrong function type for context
  • Copy/paste from parameterized function

See also

  • E07450: unexpected parameters (this error)
  • E07460: single parameter required

Examples

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

Fails with E07450: function must have no parameters

#!ek9
defines module error.e07450.bad

  defines function

    howMany()
      -> count as Integer
      <- rtn as Integer: count

    firstOnes()
      collection <- List() of String

      //head calls the function with no arguments
      cat ["last", "first"] | head howMany > collection

Fixed: head calls its function with no arguments: give it one that takes none

#!ek9
defines module error.e07450.good.fix

  defines function

    howMany()
      <- rtn as Integer: 1

    firstOnes()
      collection <- List() of String

      //head calls the function with no arguments
      cat ["last", "first"] | head howMany > collection

Fixed: Give head a function that takes no parameters

#!ek9
defines module error.e07450.good

  defines function

    howMany()
      <- rtn as Integer: 1

    firstOnes()
      <- rtn as List of String: List()
      cat ["last", "first"] | head howMany > rtn

Questions and answers

These Q&A entries show E07450 and its fix:

Found a problem?

If EK9 reported E07450 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.