Opened 7 months ago

Closed 7 months ago

#12872 closed bug (duplicate)

Pattern synonyms allow multiple type signatures but only use the first

Reported by: jophish Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.1
Keywords: PatternSynonyms 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):
Wiki Page:

Description

GHC seems to only be using the first signature for pattern synonyms

GHC 8.0.2 allows this to compile:

{-# LANGUAGE PatternSynonyms #-}
module Pattern where

pattern Foo :: ()
pattern Foo :: Bool
pattern Foo = ()

but not this:

{-# LANGUAGE PatternSynonyms #-}
module Pattern where

pattern Foo :: Bool
pattern Foo :: ()
pattern Foo = ()

This compiles and ghci tells me the type of Foo is ():

{-# LANGUAGE PatternSynonyms #-}
module Pattern where

pattern Foo :: ()
pattern Foo :: Bool
pattern Foo <- _
  where Foo = undefined

This doesn't compile (as expected):

{-# LANGUAGE PatternSynonyms #-}
module Pattern where

pattern Foo :: ()
pattern Foo :: Bool Bool
pattern Foo = ()

Change History (2)

comment:1 Changed 7 months ago by mpickering

This is fixed in HEAD.

[1 of 1] Compiling Pattern          (.hs -> .o)

test.hs:5:10: error:
    Duplicate pattern synonym signatures for ‘Foo’
    at test.hs:4:10-12
       test.hs:5:10-12

comment:2 Changed 7 months ago by mpickering

Keywords: PatternSynonyms added
Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.