parser-ts
parser-ts copied to clipboard
P.either should fail with fatal error, if second parser failed with fatal, or should it?
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
Hmm. We could also use the Semigroup for boolean so that if a fatal error is encountered it always escalated?
@IMax153 yes that sounds even better!