E188: VarArgs Param Cannot Be Given

This error occurs when a repeated parameter (varargs) is declared in a using or implicit clause.

Repeated parameters cannot be used as given/implicit parameters because they could always be satisfied by providing zero arguments, which defeats the purpose of an implicit argument.


Longer explanation:

It is not possible to define a given with a repeated parameter type. This hypothetical given parameter could always be satisfied by providing 0 arguments, which defeats the purpose of a given argument.


Example

def example(using xs: Int*): Seq[Int] = xs

Error

-- [E188] Syntax Error: example.scala:1:22 -------------------------------------
1 |def example(using xs: Int*): Seq[Int] = xs
  |                      ^^^^
  |                     repeated parameters are not allowed in a using clause
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | It is not possible to define a given with a repeated parameter type. This hypothetical given parameter could always be satisfied by providing 0 arguments, which defeats the purpose of a given argument.
   -----------------------------------------------------------------------------

Solution

Use a regular parameter list for varargs:

def example(xs: Int*): Seq[Int] = xs

Or use a sequence type for the given parameter:

def example(using xs: Seq[Int]): Seq[Int] = xs