Skip to content

Commit

Permalink
improvement: Don't use format since it seems to break at some chars
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Dec 5, 2024
1 parent 4aa1e0f commit 4179938
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class LegacyScanner(input: Input, dialect: Dialect) {
}

@inline
def reportIllegalCharacter(): Unit = curr
.setInvalidToken(s"illegal character '\\u${"%04x".format(ch)}'")
def reportIllegalCharacter(): Unit =
curr.setInvalidToken("illegal unicode codepoint: 0x" + ch.toHexString)

(ch: @switch) match {
case ' ' =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,7 @@ class TokenizerSuite extends BaseTokenizerSuite {
|""".stripMargin.replace("'''", "\"\"\"").nl2lf
assertTokenizedAsStructureLines(code, struct)
}

test("unexpected-character") {
val code = """|
|val 。 = 123
Expand All @@ -2145,7 +2146,7 @@ class TokenizerSuite extends BaseTokenizerSuite {
val struct = s"""|BOF [0..0)
|LF [0..1)
|KwVal [1..4)
|Invalid(illegal character '\\u3002') [5..6)
|Invalid(illegal unicode codepoint: 0x3002) [5..6)
|MultiHS(3) [4..7)
|Equals [7..8)
|Space [8..9)
Expand Down

0 comments on commit 4179938

Please sign in to comment.