Skip to content

Commit d6b9749

Browse files
authored
Merge pull request #1667 from maseev/iss1589-literal-error-message
Add error message for illegal literals - Parser.scala:602
2 parents 4f675c3 + a4a8f48 commit d6b9749

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ object Parsers {
599599
case FALSE => false
600600
case NULL => null
601601
case _ =>
602-
syntaxErrorOrIncomplete("illegal literal")
602+
syntaxErrorOrIncomplete(IllegalLiteral())
603603
null
604604
})
605605
}

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,4 +754,18 @@ object messages {
754754
|${"square(ints: _*) // res1: List[Int] = List(4, 9, 16)"}
755755
|""".stripMargin
756756
}
757+
758+
case class IllegalLiteral()(implicit ctx: Context) extends Message(28) {
759+
val kind = "Syntax"
760+
val msg = "illegal literal"
761+
val explanation =
762+
hl"""|Available literals can be divided into the several groups:
763+
| - Integer literals: 0, 21, 0xFFFFFFFF, -42L
764+
| - Floating Point Literals: 0.0, 1e30f, 3.14159f, 1.0e-100, .1
765+
| - Boolean Literals: true, false
766+
| - Character Literals: 'a', '\u0041', '\n'
767+
| - String Literals: "Hello, World!"
768+
| - null
769+
|"""
770+
}
757771
}

0 commit comments

Comments
 (0)