diff --git a/parser/src/lexer.rs b/parser/src/lexer.rs index 636352fa5..c51453682 100644 --- a/parser/src/lexer.rs +++ b/parser/src/lexer.rs @@ -140,12 +140,13 @@ impl<'a> Lexer<'a> { self.eat_while(|b| b.is_some() && b.unwrap().is_ascii_digit()); match self.peek() { Some(b'_') => { + self.eat_and_assert(|b| b == b'_'); + if start == self.offset { // before the underscore, there was no digit return Err(Error::BadNumber((start, self.offset - start).into())); } - self.eat_and_assert(|b| b == b'_'); match self.peek() { Some(b) if b.is_ascii_digit() => continue, // Continue if next is a digit _ => { @@ -953,6 +954,13 @@ mod tests { token_type: Some(TokenType::TK_INTEGER), }, ), + ( + b"9_223_372_036_854_775_807".as_slice(), + Token { + value: b"9_223_372_036_854_775_807".as_slice(), + token_type: Some(TokenType::TK_INTEGER), + }, + ), ( b"123.456".as_slice(), Token {