E006: Missing Ident
This error is emitted when a referenced identifier (value, method, type, etc.) cannot be found in the current scope.
Each identifier in Scala needs a matching declaration. There are two kinds of identifiers: type identifiers and value identifiers. Value identifiers are introduced by val, def, or object declarations. Type identifiers are introduced by type, class, enum, or trait declarations.
Identifiers refer to matching declarations in their environment, or they can be imported from elsewhere.
Possible reasons why no matching declaration was found:
- The declaration or the use is mis-spelt.
- An import is missing.
Example
val result = unknownIdentifier
Error
-- [E006] Not Found Error: example.scala:1:13 ----------------------------------
1 |val result = unknownIdentifier
| ^^^^^^^^^^^^^^^^^
| Not found: unknownIdentifier
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Each identifier in Scala needs a matching declaration. There are two kinds of
| identifiers: type identifiers and value identifiers. Value identifiers are introduced
| by `val`, `def`, or `object` declarations. Type identifiers are introduced by `type`,
| `class`, `enum`, or `trait` declarations.
|
| Identifiers refer to matching declarations in their environment, or they can be
| imported from elsewhere.
|
| Possible reasons why no matching declaration was found:
| - The declaration or the use is misspelled.
| - An import is missing.
| - The declaration exists but refers to a type in a context where a term is expected, or vice-versa.
-----------------------------------------------------------------------------
Solution
// Declare the identifier before using it
val unknownIdentifier = 42
val result = unknownIdentifier
// Or import it from another scope
import scala.math.Pi
val result = Pi
// Fix the spelling if it was a typo
val knownIdentifier = 42
val result = knownIdentifier
In this article