Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Or chains issue introduced in recent versions #190

Closed
Jure-BB opened this issue Jan 6, 2025 · 2 comments · Fixed by #191
Closed

Or chains issue introduced in recent versions #190

Jure-BB opened this issue Jan 6, 2025 · 2 comments · Fixed by #191

Comments

@Jure-BB
Copy link

Jure-BB commented Jan 6, 2025

Hello,

I've noticed an issue with Or chains after upgrading to recent versions.

Minimal example:

using Parlot.Fluent;
using static Parlot.Fluent.Parsers;

var p1 = Terms.Char('-').Or(Terms.Char('–')).ElseError("Expected separator");
var p2 = Terms.Char('-').Or(Terms.Char('–')).Or(Terms.Char('—')).ElseError("Expected separator");

var input   = " - ";
var result1 = p1.Parse(input);
Console.WriteLine("Parser 1 succeeded");
var result2 = p2.Parse(input); // Error: Expected separator (No error when using v1.1.0 or older)
Console.WriteLine("Parser 2 succeeded");

It looks like this bug has been introduced in #177.
Reverting OneOf implementation to an earlier version fixes the issue.

@sebastienros
Copy link
Owner

Thanks for the repro, it helped a lot.

@Jure-BB
Copy link
Author

Jure-BB commented Jan 6, 2025

Thanks for the rapid bug fix.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants