Skip to content

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

@regevbr

Description

@regevbr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions