[kotlin mode]: Fix unsigned long literal token #14295

Merged
marijnh merged 1 commit from github/fork/flofriday/master into master 2025-08-21 15:03:25 +02:00
marijnh commented 2025-08-21 15:01:10 +02:00 (Migrated from gitlab.com)

From the Kotlin Spec section 1.2.3 Literals there are only 3 Rules that define suffixes for literals:

FloatLiteral:
    DoubleLiteral ('f' |'F')
    | DecDigits ('f' |'F')

UnsignedLiteral
    (IntegerLiteral | HexLiteral | BinLiteral) ('u' |'U') ['L']

LongLiteral
    (IntegerLiteral | HexLiteral | BinLiteral)'L'

Ignoring casesensitivity we can catch them all with the regex (ul?|l|f) however the current regex for Kotlin suffixes looks like (u|ll?|l|f) which leads to the following inconsistency:

// Correctly highlighted by Codemirror and valid Kotlin
val a = 13u
val b = 24L

// Incorrectly highlighted by Codemirror but valid Kotlin
val c = 26UL

// Highlighted as one number but invalid Kotlin
val d = 72LL
From the [Kotlin Spec](https://kotlinlang.org/spec/pdf/kotlin-spec.pdf) section _1.2.3 Literals_ there are only 3 Rules that define suffixes for literals: ```ebnf FloatLiteral: DoubleLiteral ('f' |'F') | DecDigits ('f' |'F') UnsignedLiteral (IntegerLiteral | HexLiteral | BinLiteral) ('u' |'U') ['L'] LongLiteral (IntegerLiteral | HexLiteral | BinLiteral)'L' ``` Ignoring casesensitivity we can catch them all with the regex `(ul?|l|f)` however the current regex for Kotlin suffixes looks like `(u|ll?|l|f)` which leads to the following inconsistency: ```kotlin // Correctly highlighted by Codemirror and valid Kotlin val a = 13u val b = 24L // Incorrectly highlighted by Codemirror but valid Kotlin val c = 26UL // Highlighted as one number but invalid Kotlin val d = 72LL ```
marijnh commented 2025-08-21 15:03:25 +02:00 (Migrated from gitlab.com)

Merged by: marijnh at 2025-08-21 13:03:25 UTC

*Merged by: marijnh at 2025-08-21 13:03:25 UTC*
marijnh (Migrated from gitlab.com) closed this pull request 2025-08-21 15:03:25 +02:00
marijnh (Migrated from gitlab.com) merged commit into master 2025-08-21 15:03:25 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/codemirror5!14295
No description provided.