Back to Scala3

E056: Missing Type Parameter For

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

3.8.41.1 KB
Original Source

E056: Missing Type Parameter For

This error is emitted when a higher-kinded type or type constructor is used where a fully applied type is expected.

A type constructor (like List or Option) needs to be applied to type arguments before it can be used as a value type. For example, List by itself is a type constructor, but List[Int] is a proper type.


Example

scala
val items: List = List(1, 2, 3)

Error

scala
-- [E056] Syntax Error: example.scala:1:11 -------------------------------------
1 |val items: List = List(1, 2, 3)
  |           ^^^^
  |           Missing type parameter for List

Solution

scala
// Provide the type parameter
val items: List[Int] = List(1, 2, 3)
scala
// Or let the compiler infer the type
val items = List(1, 2, 3)
<!-- 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>