Skip to content

fix(number): allow float prefixes before non-exponent text - #1889

Open
sb123sb123 wants to merge 1 commit into
rust-bakery:mainfrom
sb123sb123:fix/1725-recognize-float-exponent
Open

sb123sb123 wants to merge 1 commit into
rust-bakery:mainfrom
sb123sb123:fix/1725-recognize-float-exponent

Conversation

@sb123sb123

Copy link
Copy Markdown

Fixes #1725

Cause

The optional exponent parser uses cut(digit1) after consuming e or E. When that character starts ordinary trailing text, as in 123episode, the digit parser returns a fatal error instead of allowing the optional exponent to be skipped. The valid prefix 123 is therefore rejected.

Fix

Keep the cut behavior when an exponent reaches end-of-input, preserving the existing malformed/incomplete exponent behavior. When non-digit trailing input follows e or E, let the optional exponent backtrack. Apply the same parser change to complete, streaming, and mode-generic float recognizers.

Validation

  • cargo +nightly test --offline -p nom — passed (208 library tests; all package integration tests and doctests passed).
  • cargo +nightly test --offline -p nom --no-default-features — passed (324 doctests).
  • cargo +nightly test --offline -p nom --no-default-features --features alloc — passed (324 doctests).
  • cargo +nightly test --offline -p nom --features std — passed (324 doctests).
  • cargo +nightly test --offline -p nom --no-default-features --features alloc,std — passed (324 doctests).
  • cargo +nightly build --offline -p nom and the minimal alloc,std build — passed.
  • cargo +nightly fmt --all -- --check — passed.
  • cargo +nightly bench --offline --features "" — passed.
  • The standalone regression reproducer now returns Ok(("episode", "123")); the same reproducer on the base commit returned Err(Failure(... code: Digit)).
  • Stable focused checks before the host's stable Cargo component became unavailable: cargo test --offline --lib float_test (3 passed) and cargo test --offline --test float (6 passed).

Baseline limitations

The exact workspace test and documentation commands cannot complete on this Windows host because the unrelated benchmarks member's jemalloc-sys build reports “C compiler cannot create executables” (exit 77). Package documentation with RUSTDOCFLAGS=-D warnings also encounters existing rustdoc::redundant-explicit-links warnings in src/combinator/mod.rs. Beta and 1.65 toolchains were not installed, and stable Cargo was removed by a concurrent host job after the focused checks. These limitations are unrelated to this patch.

AI assistance disclosure

This PR was developed with autonomous GPT-5.6 assistance. Issue triage, reproduction, implementation, validation, diff inspection, commit signing, and submission were performed by the agent in the remote workspace.

@sb123sb123
sb123sb123 requested a review from Geal as a code owner September 21, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Float parsing with trailing e broken

1 participant