Commit e5ba3608 authored by cactus's avatar cactus

rnMethodBind: reject pattern synonyms in instance definitions (fixes #9705)

parent 65346865
......@@ -745,6 +745,11 @@ rnMethodBind _ _ (L loc bind@(PatBind {})) = do
addErrAt loc (methodBindErr bind)
return (emptyBag, emptyFVs)
-- Associated pattern synonyms are not implemented yet
rnMethodBind _ _ (L loc bind@(PatSynBind {})) = do
addErrAt loc $ methodPatSynErr bind
return (emptyBag, emptyFVs)
rnMethodBind _ _ b = pprPanic "rnMethodBind" (ppr b)
\end{code}
......@@ -1061,6 +1066,11 @@ methodBindErr mbind
= hang (ptext (sLit "Pattern bindings (except simple variables) not allowed in instance declarations"))
2 (ppr mbind)
methodPatSynErr :: HsBindLR RdrName RdrName -> SDoc
methodPatSynErr mbind
= hang (ptext (sLit "Pattern synonyms not allowed in instance declarations"))
2 (ppr mbind)
bindsInHsBootFile :: LHsBindsLR Name RdrName -> SDoc
bindsInHsBootFile mbinds
= hang (ptext (sLit "Bindings in hs-boot files are not allowed"))
......
{-# LANGUAGE PatternSynonyms #-}
class C a where
pattern P = ()
T9705.hs:3:5:
Pattern synonyms not allowed in instance declarations
pattern P = ()
......@@ -6,3 +6,4 @@ test('T8961', normal, multimod_compile_fail, ['T8961',''])
test('as-pattern', normal, compile_fail, [''])
test('T9161-1', normal, compile_fail, [''])
test('T9161-2', normal, compile_fail, [''])
test('T9705', 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