E102: Undefined Named Type Parameter

This error is emitted when a named type argument refers to a type parameter that does not exist in the definition.

When using named type arguments, you must use the exact names of the type parameters as declared in the method or class definition.


Example

import scala.language.experimental.namedTypeArguments

def example[A, B](a: A, b: B): (A, B) = (a, b)

val result = example[A = Int, C = String](1, "hello")

Error

-- [E102] Syntax Error: example.scala:5:34 -------------------------------------
5 |val result = example[A = Int, C = String](1, "hello")
  |                                  ^^^^^^
  |                      Type parameter C is undefined. Expected one of A, B.

Solution

// Use the correct, existing, type parameter name
import scala.language.experimental.namedTypeArguments

def example[A, B](a: A, b: B): (A, B) = (a, b)

val result = example[A = Int, B = String](1, "hello")