Commit 2a3af152 authored by seraphime's avatar seraphime Committed by Ben Gamari
Browse files

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: https://phabricator.haskell.org/D2361

GHC Trac Issues: #12165
parent afec447c
......@@ -988,6 +988,7 @@ findDupSigs sigs
expand_sig sig@(InlineSig n _) = [(n,sig)]
expand_sig sig@(TypeSig ns _) = [(n,sig) | n <- ns]
expand_sig sig@(ClassOpSig _ ns _) = [(n,sig) | n <- ns]
expand_sig sig@(PatSynSig ns _ ) = [(n,sig) | n <- ns]
expand_sig _ = []
matching_sig (L _ n1,sig1) (L _ n2,sig2) = n1 == n2 && mtch sig1 sig2
......@@ -995,6 +996,7 @@ findDupSigs sigs
mtch (InlineSig {}) (InlineSig {}) = True
mtch (TypeSig {}) (TypeSig {}) = True
mtch (ClassOpSig d1 _ _) (ClassOpSig d2 _ _) = d1 == d2
mtch (PatSynSig _ _) (PatSynSig _ _) = True
mtch _ _ = False
-- Warn about multiple MINIMAL signatures
......
{-# LANGUAGE PatternSynonyms #-}
module ShouldFail where
pattern P :: a -> b -> Maybe (a,b)
pattern P :: foo => bar => blah -> urgh
pattern P x y = Just (x, y)
T12165.hs:5:9: error:
Duplicate pattern synonym signatures for ‘P’
at T12165.hs:4:9
T12165.hs:5:9
......@@ -31,3 +31,4 @@ test('T11053', normal, compile, ['-fwarn-missing-pattern-synonym-signatures'])
test('T10426', normal, compile_fail, [''])
test('T11265', normal, compile_fail, [''])
test('T11667', normal, compile_fail, [''])
test('T12165', normal, compile_fail, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment