E088: Expected Start Of Top Level Definition

This error is emitted when modifiers are provided but no valid definition follows them.

After using modifiers like private, protected, final, abstract, etc., you must provide a definition such as class, trait, object, enum, def, val, or var.


Example

final

Error

-- [E088] Syntax Error: example.scala:1:5 --------------------------------------
1 |final
  |     ^
  |     Expected start of definition
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | You have to provide either class, trait, object, or enum definitions after modifiers
   -----------------------------------------------------------------------------

Solution

// Add a definition after the modifier
final class Example
// Or for methods/values
final val x = 42