You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In updating one of my projects to nom 8, I noticed one of my tests started failing. I narrowed it down to the combination of nom::combinator::recognize and nom::character::complete::multispace0 being broken if multispace0 consumes the entire input.
In more detail, when adding the following test to src/combinator/tests.rs, cases A-C pass, but case D fails. This seems to have worked correctly in nom 7.
#[test]fnrecognize_issue(){usecrate::character::complete::{multispace0, multispace1};let input = "\na";// Case Aassert_eq!(
recognize::<_,crate::error::Error<_>, _>(multispace1).parse(input),Ok(("a","\n")));// Case Bassert_eq!(
recognize::<_,crate::error::Error<_>, _>(multispace0).parse(input),Ok(("a","\n")));let input = "\n";// Case Cassert_eq!(
recognize::<_,crate::error::Error<_>, _>(multispace1).parse(input),Ok(("","\n")));// Case Dassert_eq!(
recognize::<_,crate::error::Error<_>, _>(multispace0).parse(input),Ok(("","\n")));}
The text was updated successfully, but these errors were encountered:
I have run into a similar bug in 8.0.0 when using recognize and consumed with a digit0 parser that consumes all:
use nom::{Parser, character::complete::digit0, combinator::recognize};#[test]fndigit_parser(){letmut p = recognize(digit0::<&str,()>);// If `digit0` doesn't consume the entire input then everything works as expectedlet s = "1234A";let(rem, res) = p.parse(s).unwrap();assert_eq!(rem,"A");assert_eq!(res,"1234");// But if `digit0` does consume the entire input then the result is incorrectlet s = "1234";let(rem, res) = p.parse(s).unwrap();assert_eq!(rem,"");assert_eq!(res,"1234");}
In updating one of my projects to nom 8, I noticed one of my tests started failing. I narrowed it down to the combination of
nom::combinator::recognize
andnom::character::complete::multispace0
being broken ifmultispace0
consumes the entire input.In more detail, when adding the following test to
src/combinator/tests.rs
, cases A-C pass, but case D fails. This seems to have worked correctly in nom 7.The text was updated successfully, but these errors were encountered: