parsec
parsec copied to clipboard
conflict between infix and prefix ops in `Text.Parser.Expr`
The function buildExpressionParser
in module Text.Parser.Expr
has a bug.
In the uncommon case where a prefix operator has lower precedence than an infix operator, such as in boolean expressions, e.g
-
&&
is an infix operator. -
!
is a prefix operator of lower precedence.
The input !a && b
is correctly parsed Not (And a b)
, but the parser fails to parse a && !b
(as And a (Not b)
).