Skip to content

Commit

Permalink
Merge pull request #710 from epage/repeat
Browse files Browse the repository at this point in the history
fix(comb): Fix repeat().fold(1..) to append errors
  • Loading branch information
epage authored Jan 23, 2025
2 parents a2905d4 + f8f0cb4 commit 23d51df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/combinator/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ where
///
/// assert_eq!(parser("abcabc"), Ok(("", vec!["abc", "abc"])));
/// assert_eq!(parser("abc123"), Ok(("123", vec!["abc"])));
/// assert_eq!(parser("123123"), Err(ErrMode::Backtrack(InputError::new("123123", ErrorKind::Many))));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Many))));
/// assert_eq!(parser("123123"), Err(ErrMode::Backtrack(InputError::new("123123", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Tag))));
/// ```
///
/// Arbitrary number of repetitions:
Expand Down Expand Up @@ -1387,9 +1387,9 @@ where
E: ParserError<I>,
{
let init = init();
let start = input.checkpoint();
match f.parse_next(input) {
Err(ErrMode::Backtrack(_)) => Err(ErrMode::from_error_kind(input, ErrorKind::Many)),
Err(e) => Err(e),
Err(e) => Err(e.append(input, &start, ErrorKind::Many)),
Ok(o1) => {
let mut acc = g(init, o1);

Expand Down
2 changes: 1 addition & 1 deletion src/combinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ fn fold_repeat1_test() {
multi(Partial::new(c)),
Err(ErrMode::Backtrack(error_position!(
&Partial::new(c),
ErrorKind::Many
ErrorKind::Tag
)))
);
assert_eq!(
Expand Down

0 comments on commit 23d51df

Please sign in to comment.