Back to Scala3

E015: Repeated Modifier

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

3.8.41.4 KB
Original Source

E015: Repeated Modifier

This error is emitted when the same modifier is specified more than once on a definition. Each modifier should only appear once.


Example

scala
private private val x = 1

Error

scala
-- [E015] Syntax Error: example.scala:1:8 --------------------------------------
1 |private private val x = 1
  |        ^^^^^^^
  |        Repeated modifier private
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | This happens when you accidentally specify the same modifier twice.
  |
  | Example:
  |
  | private private val Origin = Point(0, 0)
  |
  | instead of
  |
  | private final val Origin = Point(0, 0)
   -----------------------------------------------------------------------------

Solution

scala
// Remove the duplicate modifier
private val x = 1
scala
// If you meant to use different modifiers, use the correct combination
private final val x = 1
<!-- 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>