Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

P.either should fail with fatal error, if second parser failed with fatal, or should it? #47

Open
regevbr opened this issue Jun 30, 2021 · 2 comments

Comments

@regevbr
Copy link

regevbr commented Jun 30, 2021

Take a look at the following test (which currently fails):

const fatalParser: P.Parser<Char, Char> = i => error(i, ['expected'], true)
const parser5 = P.either(C.char('a'), () => fatalParser)
assert.deepStrictEqual(S.run('c')(parser5), error(stream(['c']), ['"a"', 'expected'], true))

I believe that the semigroup of ParserResult should use getLastSemigroup on the fatal property, and not getFirstSemigroup. I guess it is kind of a philosophical question as one can argue that I'm mistaken....

@gcanti thoughts?

If you think this should indeed be fixed, I have a PR ready to go

@IMax153
Copy link
Collaborator

IMax153 commented Jun 30, 2021

Hmm. We could also use the Semigroup for boolean so that if a fatal error is encountered it always escalated?

@regevbr
Copy link
Author

regevbr commented Jun 30, 2021

@IMax153 yes that sounds even better!

regevbr added a commit to regevbr/parser-ts that referenced this issue Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants