Back to Scala3

E178: Missing Argument List

docs/_docs/reference/error-codes/E178.md

3.8.41.9 KB
Original Source

E178: Missing Argument List

This error occurs when a method with multiple parameter lists is called without providing all the required argument lists.

In Scala, methods can have multiple parameter lists (curried methods). When calling such methods, all parameter lists must be provided unless the partially applied method is explicitly expected as a function type.

Unapplied methods are only converted to functions when a function type is expected.


Example

scala
object Test:
  def multiParam()()(x: Int): Int = x
  multiParam()  // missing argument lists

Error

scala
-- [E178] Type Error: example.scala:3:12 ---------------------------------------
3 |  multiParam()  // missing argument lists
  |  ^^^^^^^^^^^^
  |  missing argument list for method multiParam in object Test
  |
  |    def multiParam()()(x: Int): Int
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Unapplied methods are only converted to functions when a function type is expected.
   -----------------------------------------------------------------------------

Solution

Provide all required argument lists:

scala
object Test:
  def multiParam()()(x: Int): Int = x
  val result = multiParam()()(42)  // provide all argument lists

Or explicitly convert to a function if partial application is intended:

scala
object Test:
  def multiParam()()(x: Int): Int = x
  val partialFn: Int => Int = multiParam()()  // explicit function type
<!-- SOURCE-ONLY: Remove the notice below once this page has been manually updated. --> <aside class="warning"> This reference page was created with LLM assistance - the description of the error code may not be accurate or cover all possible scenarios. </aside>