E100: Missing Empty Argument List

This error is emitted when a nullary method (a method with an empty parameter list ()) is called without the empty argument list.

In Scala 3, the application syntax must follow exactly the parameter syntax. If a method is defined with (), it must be called with (). This rule doesn't apply to methods defined in Java or that override Java methods.


Example

def next(): Int = 42

val n = next

Error

-- [E100] Syntax Error: example.scala:3:8 --------------------------------------
3 |val n = next
  |        ^^^^
  |        method next must be called with () argument
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Previously an empty argument list () was implicitly inserted when calling a nullary method without arguments. E.g.
  |
  | def next(): T = ...
  |         |next     // is expanded to next()
  |
  | In Dotty, this idiom is an error. The application syntax has to follow exactly the parameter syntax.
  | Excluded from this rule are methods that are defined in Java or that override methods defined in Java.
   -----------------------------------------------------------------------------

Solution

// Include the empty argument list
def next(): Int = 42

val n = next()
// Or define without () if no arguments are needed
def next: Int = 42

val n = next