support float without fractional part

This commit is contained in:
TcMits
2025-09-05 12:58:28 +07:00
parent 6d80d862ee
commit f2d4087462

View File

@@ -590,7 +590,7 @@ impl<'a> Lexer<'a> {
self.eat_and_assert(|b| b == b'.');
match self.peek() {
Some(b) if b.is_ascii_digit() => {
Some(b) if b.is_ascii_digit() || b.eq_ignore_ascii_case(&b'e') => {
self.eat_while_number_digit()?;
match self.peek() {
Some(b'e') | Some(b'E') => {
@@ -1239,6 +1239,14 @@ mod tests {
token_type: Some(TokenType::TK_ID),
},
),
// issue 2933
(
b"1.e5".as_slice(),
Token {
value: b"1.e5".as_slice(), // 'X' is not included in the value
token_type: Some(TokenType::TK_FLOAT),
},
),
];
for (input, expected) in test_cases {