Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

try_map loses some of what is expected in error when used sequentially #827

Description

@Hedgehogo

Test content:

use crate::{DefaultExpected, LabelError};

fn parser<'input>() -> impl Parser<'input, &'input str, (), extra::Err<Rich<'input, char>>> {
    group((
        just("a").or_not(),
        just("b").try_map(|_, _| Ok(())).or_not(),
        just("c"),
    ))
    .ignored()
}

assert_eq!(
    parser().parse("").into_output_errors(),
    (
        None,
        vec![LabelError::<&str, _>::expected_found(
            vec![
                DefaultExpected::Token('a'.into()),
                DefaultExpected::Token('b'.into()),
                DefaultExpected::Token('c'.into()),
            ],
            None,
            SimpleSpan::new((), 0..0)
        )]
    )
);

Execution result:

assertion `left == right` failed
  left: (None, [found end of input at 0..0 expected ''b'', or ''c''])
 right: (None, [found end of input at 0..0 expected ''a'', ''b'', or ''c''])

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions