E07470: function must have a two parameters

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

What went wrong

A function or operator requires EXACTLY two parameters but has a different number.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 124 (How do I group and aggregate collection data in EK9?)

[BINARY OPERATORS (require two parameters)] +, -, *, /, ==, <, >, <=, >=, <>, <=>

How to fix it

  1. Provide exactly two parameters

Common causes

  • Missing parameter
  • Extra parameters

See also

  • E07470: two parameters required (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 E07470: function must have a two parameters

#!ek9
defines module error.e07470.bad

  defines function

    byLength()
      -> word as String
      <- rtn as Integer: length word

    sortWords()
      <- rtn as List of String: List()

      //sort compares two items at a time
      cat ["three", "one", "seven"] | sort byLength > rtn

Fixed: Give sort a function of two parameters

#!ek9
defines module error.e07470.good

  defines function

    byLength()
      ->
        first as String
        second as String
      <- rtn as Integer: length first <=> length second

    sortWords()
      <- rtn as List of String: List()
      cat ["three", "one", "seven"] | sort byLength > rtn

Questions and answers

These Q&A entries show E07470 and its fix:

Found a problem?

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