diff --git a/package/origlang-compiler/src/lexer.rs b/package/origlang-compiler/src/lexer.rs index 932567b5..e8108995 100644 --- a/package/origlang-compiler/src/lexer.rs +++ b/package/origlang-compiler/src/lexer.rs @@ -300,7 +300,7 @@ impl Lexer<'_> { let r = self.byte_skip_n(plus); if let Ok(b) = r { - if (b'0'..b'9').contains(&b) { + if (b'0'..=b'9').contains(&b) { plus += 1; } else { break diff --git a/package/origlang-compiler/src/lexer/tests.rs b/package/origlang-compiler/src/lexer/tests.rs index 01e6faef..d5ffc82a 100644 --- a/package/origlang-compiler/src/lexer/tests.rs +++ b/package/origlang-compiler/src/lexer/tests.rs @@ -217,3 +217,19 @@ fn crlf_negative() { char: '\r', }); } + +#[test] +fn off_by_one_range_regression() { + const S: &str = "9"; + let lexer = Lexer::create(S); + assert_eq!(lexer.next(), Pointed { + data: Token::Digits { + sequence: "9".to_string(), + suffix: None, + }, + position: SourcePosition { + line: NonZeroUsize::new(1).unwrap(), + column: NonZeroUsize::new(1).unwrap(), + } + }) +} \ No newline at end of file