Skip to content

Commit

Permalink
Merge pull request #3603 from kitbellew/sbt299_17
Browse files Browse the repository at this point in the history
LegacyScanner: allow repeated number separators
  • Loading branch information
kitbellew committed Feb 29, 2024
2 parents 48a0221 + 2fff6ae commit adc2272
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Expand Up @@ -765,12 +765,12 @@ class LegacyScanner(input: Input, dialect: Dialect) {
putChar(ch)
nextChar()
readDigits(base)
} else if (wasSeparator) {
val pos = if (ch == SU) begCharOffset else begCharOffset - 1
syntaxError("trailing number separator", at = pos)
} else if (isNumberSeparator()) {
nextChar()
readDigits(base, true)
} else if (wasSeparator) {
val pos = if (ch == SU) begCharOffset else begCharOffset - 1
syntaxError("trailing number separator", at = pos)
}

/**
Expand Down
Expand Up @@ -1136,7 +1136,17 @@ class TokenizerSuite extends BaseTokenizerSuite {
}
}

Seq("1_024", "1_024L", "3_14e-2", "3_14E-2_1").foreach { value =>
Seq(
"1_024",
"1_024L",
"3_14e-2",
"3_14E-2_1",
"3_14E-1__2",
"0x_1234",
"0b_0101",
"123_456__789",
"0x__123_456__789"
).foreach { value =>
test(s"numeric literal separator ok scala213: $value") {
dialects.Scala213(value).tokenize.get // no exception
}
Expand Down Expand Up @@ -1191,12 +1201,6 @@ class TokenizerSuite extends BaseTokenizerSuite {
|3_14ef
| ^""".stripMargin
),
(
"3_14E-1__2",
"""|<input>:1: error: trailing number separator
|3_14E-1__2
| ^""".stripMargin
),
(
"3_14E-2_",
"""|<input>:1: error: trailing number separator
Expand Down

0 comments on commit adc2272

Please sign in to comment.