Suffix format advances past an unrelated invalid byte
Description
With a base suffix configured, from_lexical_partial_with_options can count an unrelated invalid byte as consumed. from_lexical_with_options can consequently report the next byte as the invalid digit.
Prerequisites
- Rust version: 1.94.1
- lexical-parse-integer version: 1.0.6
- Features:
format,power-of-two - Direct dependency:
lexical-util1.0.7 withformatandpower-of-two
Test case
use core::num::NonZeroU8;
use lexical_parse_integer::{FromLexicalWithOptions, Options};
use lexical_util::format::NumberFormatBuilder;
fn main() {
const FORMAT: u128 = NumberFormatBuilder::new()
.base_suffix(NonZeroU8::new(b'h')).build_strict();
let result = u8::from_lexical_partial_with_options::<FORMAT>(b"12?x", &Options::new());
assert_eq!(result, Ok((12, 2))); // actual: Ok((12, 3))
}
Additional Context
For the same input, complete parsing returns InvalidDigit(3) instead of InvalidDigit(2). The configured suffix is h, not ?.
Change history
- v1 · created · 2026-11-10 01:49 UTC
{ "title": "Suffix format advances past an unrelated invalid byte", "body": "## Description\n\nWith a base suffix configured, `from_lexical_partial_with_options` can count an unrelated invalid byte as consumed. `from_lexical_with_options` can consequently report the next byte as the invalid digit.\n\n## Prerequisites\n\n- Rust version: 1.94.1\n- lexical-parse-integer version: 1.0.6\n- Features: `format`, `power-of-two`\n- Direct dependency: `lexical-util` 1.0.7 with `format` and `power-of-two`\n\n## Test case\n\n```rust\nuse core::num::NonZeroU8;\nuse lexical_parse_integer::{FromLexicalWithOptions, Options};\nuse lexical_util::format::NumberFormatBuilder;\n\nfn main() {\n const FORMAT: u128 = NumberFormatBuilder::new()\n .base_suffix(NonZeroU8::new(b'h')).build_strict();\n let result = u8::from_lexical_partial_with_options::<FORMAT>(b\"12?x\", &Options::new());\n assert_eq!(result, Ok((12, 2))); // actual: Ok((12, 3))\n}\n```\n\n## Additional Context\n\nFor the same input, complete parsing returns `InvalidDigit(3)` instead of `InvalidDigit(2)`. The configured suffix is `h`, not `?`.", "validity": "reported", "upstream_status": "not_reported" }