Skip to content

Commit 1d24eaa

Browse files
authored
Merge pull request #4501 from benkobalog/fix-#4500
Fix #4500 Allow keyword start after numbers
2 parents 25f829c + 1629f99 commit 1d24eaa

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object SyntaxHighlighting {
5454
@forceInline def keywordStart =
5555
prev == 0 || prev == ' ' || prev == '{' || prev == '(' ||
5656
prev == '\n' || prev == '[' || prev == ',' || prev == ':' ||
57-
prev == '|' || prev == '&'
57+
prev == '|' || prev == '&' || prev.isDigit
5858

5959
@forceInline def numberStart(c: Char) =
6060
c.isDigit && (!prev.isLetter || prev == '.' || prev == ' ' || prev == '(' || prev == '\u0000')

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SyntaxHighlightingTests {
6464
@Test
6565
def expressions = {
6666
test("val x = 1 + 2 + 3", "<K|val> <V|x> = <L|1> + <L|2> + <L|3>")
67+
test("if (true) 3 else 1", "<K|if> (<K|true>) <L|3> <K|else> <L|1>")
6768
}
6869

6970
@Test

0 commit comments

Comments
 (0)