Commit 443bf044 authored by Matthew Pickering's avatar Matthew Pickering Committed by Ben Gamari
Browse files

Allow pattern synonyms which have several clauses.

But still disallow empty pattern synonym builder declarations. Handling
this incorrectly was the cause of #11367.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1779

GHC Trac Issues: #11367
parent 67fc3f3a
......@@ -464,7 +464,7 @@ mkPatSynMatchGroup :: Located RdrName
-> P (MatchGroup RdrName (LHsExpr RdrName))
mkPatSynMatchGroup (L loc patsyn_name) (L _ decls) =
do { matches <- mapM fromDecl (fromOL decls)
; when (length matches /= 1) (wrongNumberErr loc)
; when (null matches) (wrongNumberErr loc)
; return $ mkMatchGroup FromSource matches }
where
fromDecl (L loc decl@(ValD (PatBind pat@(L _ (ConPatIn ln@(L _ name) details)) rhs _ _ _))) =
......
{-# LANGUAGE PatternSynonyms, ViewPatterns #-}
module T11367 where
pattern A :: Int -> String
pattern A n <- (read -> n) where
A 0 = "hi"
A 1 = "bye"
......@@ -48,3 +48,4 @@ test('T11224b', normal, compile, [''])
test('MoreEx', normal, compile, [''])
test('T11283', normal, compile, [''])
test('T11336', normal, compile, [''])
test('T11367', normal, compile, [''])
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