From f2d4087462571abd10825e665677efd4f98485f5 Mon Sep 17 00:00:00 2001 From: TcMits Date: Fri, 5 Sep 2025 12:58:28 +0700 Subject: [PATCH] support float without fractional part --- parser/src/lexer.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parser/src/lexer.rs b/parser/src/lexer.rs index e644b8c95..604d14bcf 100644 --- a/parser/src/lexer.rs +++ b/parser/src/lexer.rs @@ -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 {