E025: Identifier Expected
This error is emitted when the parser expects an identifier but finds something else, typically when an invalid token is used where a name is required.
This can occur when for example when a type annotation uses something that is not a valid identifier.
Example
object obj2:
val a: this = ???
Error
-- [E025] Syntax Error: example.scala:2:9 --------------------------------------
2 | val a: this = ???
| ^^^^
| identifier expected
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| An identifier expected, but this found. This could be because
| this is not a valid identifier. As a workaround, the compiler could
| infer the type for you. For example, instead of:
|
| def foo: this = {...}
|
| Write your code like:
|
| def foo = {...}
-----------------------------------------------------------------------------
Solution
object obj2:
val a: this.type = ???
In this article