Opened 12 months ago

Closed 9 months ago

#12165 closed bug (fixed)

Multiple pattern type signatures accepted

Reported by: goldfire Owned by: seraphime
Priority: normal Milestone: 8.2.1
Component: Compiler Version: 8.1
Keywords: PatternSynonyms, newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC accepts invalid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D2361
Wiki Page:


This hogwash is accepted:

pattern P :: a -> b -> Maybe (a,b)
pattern P :: foo => bar => blah -> urgh
pattern P x y = Just (x, y)

A little experimentation shows that only the first pattern signature is examined. Others are accepted and ignored.

Change History (7)

comment:1 Changed 12 months ago by mpickering

Keywords: newcomer added

comment:2 Changed 11 months ago by kgupta

Owner: set to kgupta

I would like to try to work on fixing this bug.

comment:3 Changed 11 months ago by mpickering

Differential Rev(s): Phab:D2361
Owner: changed from kgupta to seraphime

comment:4 Changed 11 months ago by mpickering

It has already been fixed sorry.

comment:5 Changed 11 months ago by Ben Gamari <ben@…>

In 2a3af152/ghc:

Treat duplicate pattern synonym signatures as an error

Fixes issue T12165 by banning duplicate pattern synonyms
signatures. This seems to me the best solution because:

   1) it is coherent with the way we treat other duplicate signatures

   2) the typechecker currently doesn't try to apply a second
       signature to a pattern to see if it matches, probably because
       it assumes there is no more than one signature per object.

Test Plan: ./validate

Reviewers: goldfire, austin, mpickering, bgamari

Reviewed By: mpickering, bgamari

Subscribers: mpickering, thomie

Differential Revision:

GHC Trac Issues: #12165

comment:6 Changed 11 months ago by bgamari

Milestone: 8.0.2
Status: newmerge

Merged. Perhaps it would be worth trying to merge this to 8.0.2.

comment:7 Changed 9 months ago by bgamari

Resolution: fixed
Status: mergeclosed

Never mind; #11727 (which allows multiple signatures to begin with) wasn't yet fixed in 8.0.1 so this issue isn't even present.

Note: See TracTickets for help on using tickets.