E06310: function must have no arguments

Category: E06xxx Type hierarchy checks · Reported in phase: FULL_RESOLUTION · Classification: REQUIRE_NO_ARGUMENTS · All error codes

What went wrong

This function/operation takes NO arguments, but you provided some.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 867 (Why must functions used with stream call take zero argume...)

How to fix it

  1. Remove arguments from call
  2. If you need parameterized version, check for overloads
  3. Maybe you intended to call a different method

Common causes

  • Calling parameterless method with arguments
  • Default constructor doesn't accept values
  • Wrong overload selected
  • Method was refactored to be parameterless

See also

  • E06310: takes NO arguments (this error)
  • E06300: requires exactly ONE argument
  • E06280: too many arguments (general)

Examples

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

Fails with E06310: function must have no arguments

#!ek9
defines module error.e06310.bad

  defines function

    doubled()
      -> number as Integer
      <- rtn as Integer: number * 2

    callNeedsArguments()
      <- rtn as List of Integer?
      //'call' calls each function with NO arguments
      rtn: cat [doubled] | call | collect as List of Integer

Fixed: Give 'call' functions that take no arguments - or 'map with' a function of one

#!ek9
defines module error.e06310.good

  defines function

    answer()
      <- rtn as Integer: 42

    doubled()
      -> number as Integer
      <- rtn as Integer: number * 2

    callAndMap()
      <- rtn as List of Integer: cat [answer] | call | map with doubled | collect as List of Integer

Questions and answers

These Q&A entries show E06310 and its fix: