Ticket #209 (new bug report)
Opened 4 years ago
Negative pattern parsing
|Reported by:||benmachine||Owned by:||nibro|
One of the constructors for the Pat type is PNeg Pat, for negated patterns. But not only is the Pat field here way too general (since -n or -(x:xs) are not valid patterns), the only circumstances in which it *is* actually valid seem to be negated literals, which are either quite capable of storing that information in their literal, or quite inappropriate to be negated (and so should be an error). Notice that -1## is a parse error in GHC since word literals must be non-negative integers.
So there's firstly an arguable bug in that parsePat "-'a'" succeeds, producing ParseOk (PNeg (PLit (Char 'a'))) which is nonsense, but there's also a wider question of whether we need PNeg at all, or whether we can drop it in favour of negation inside the literals. NegApp is clearly necessary on expressions, but there's no analogous negation of variables or compound constructions in patterns.