E028: Illegal Literal

This error is emitted when the parser encounters an invalid literal value that doesn't conform to Scala's literal syntax rules.

The compiler message states: "Illegal literal"

Available literals in Scala can be divided into several groups:

  • Integer literals: 0, 21, 0xFFFFFFFF, -42L
  • Floating Point Literals: 0.0, 1e30f, 3.14159f, 1.0e-100, .1
  • Boolean Literals: true, false
  • Character Literals: 'a', '\u0041', '\n'
  • String Literals: "Hello, World!"
  • null

This error is triggered during parsing when a literal token is expected but the scanner encounters something that cannot be interpreted as any valid literal type.

Note: This error code is active in the compiler and is triggered in the parser's literal and negativeLiteral methods. The exact conditions to reproduce this error with source code require further investigation, as the scanner typically produces different errors for malformed input.

In this article