chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Labelling parsers doesn't work sometimes

Open zyansheep opened this issue 9 months ago • 0 comments

The following code is a minimum repro. It seems that the label gets used only in certain situations for the keyword parser. This may also be the case for other parsers (like ident), but I'm not entirely sure.

fn test_label_parse(string: &str) -> ParseResult<&str, Rich<'_, char>> {
	let parser = keyword::<&str, char, &str, extra::Err<Rich<char>>>("first");
	parser.labelled("first").parse(string)
}

#[test]
fn label_test() {
	let uses_label = test_label_parse("[first");
	let incorrect = test_label_parse("firsd");
	uses_label.errors().for_each(|err|println!("{err}"));
	incorrect.errors().for_each(|err|println!("{err}"));
	panic!();
}

zyansheep avatar Sep 08 '23 13:09 zyansheep