Opened 22 months ago

Last modified 22 months ago

#11368 new bug

Pattern synonym name is mangled when patterns are non-exhaustive

Reported by: Iceland_jack Owned by: mpickering
Priority: low Milestone:
Component: Compiler Version: 8.1
Keywords: PatternSynonyms Cc:
Operating System: Linux Architecture: x86
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: #11367 Differential Rev(s):
Wiki Page:

Description (last modified by Iceland_jack)

pattern A n <- ... where
        A 0 = ...

When a pattern synonym is non-exhaustive its name is mangled:

>>> A 3
"*** Exception: /tmp/tmp.t0h0pMgwWb.hs:(4,1)-(5,14): Non-exhaustive patterns in function $bA

“Non-exhaustive patterns in pattern synonym A”

Comment from ticket #11367.

Change History (3)

comment:1 Changed 22 months ago by Iceland_jack

Description: modified (diff)

comment:2 Changed 22 months ago by mpickering

Owner: set to mpickering

comment:3 Changed 22 months ago by mpickering

This actually looks a bit more fiddly than I thought. After typechecking the pat syn is split into the builder and the matcher. Thus in the desugaring, the buider is just treated like any other function bind (line 128 in DsBinds) which is the cause of the bad error message.

A way to fix this would be to add a new constructor to IdDetails called PatSynBuilder which carries the PatSyn which was used to build the relevant Id. FunBind could then be changed to check whether the Id comes from a pat syn and modify the error message as appropriate.

Does anyone else see an easier way? I guess the error messages should refer to the right things so I'll have to make these changes.

Note: See TracTickets for help on using tickets.