Commit 6122efca authored by eir@cis.upenn.edu's avatar eir@cis.upenn.edu

Fix #8759 by not panicking with TH and patsyns.

We should still have pattern synonyms in TH, though.
parent d1dff94c
......@@ -1238,7 +1238,7 @@ rep_bind (L _ (VarBind { var_id = v, var_rhs = e}))
; return (srcLocSpan (getSrcLoc v), ans) }
rep_bind (L _ (AbsBinds {})) = panic "rep_bind: AbsBinds"
rep_bind (L _ (PatSynBind {})) = panic "rep_bind: PatSynBind"
rep_bind (L _ dec@(PatSynBind {})) = notHandled "pattern synonyms" (ppr dec)
-----------------------------------------------------------------------------
-- Since everything in a Bind is mutually recursive we need rename all
-- all the variables simultaneously. For example:
......
......@@ -70,6 +70,7 @@ import Class
import Inst
import TyCon
import CoAxiom
import PatSyn ( patSynId )
import ConLike
import DataCon
import TcEvidence( TcEvBinds(..) )
......@@ -1173,6 +1174,8 @@ reifyThing (AGlobal (AConLike (RealDataCon dc)))
; return (TH.DataConI (reifyName name) ty
(reifyName (dataConOrigTyCon dc)) fix)
}
reifyThing (AGlobal (AConLike (PatSynCon ps)))
= noTH (sLit "pattern synonyms") (ppr $ patSynId ps)
reifyThing (ATcId {tct_id = id})
= do { ty1 <- zonkTcType (idType id) -- Make use of all the info we have, even
......
{-# LANGUAGE TemplateHaskell, PatternSynonyms #-}
module T8759 where
import Language.Haskell.TH
pattern P = ()
$( do info <- reify 'P
reportWarning (show info)
return [] )
T8759.hs:9:4:
Can't represent pattern synonyms in Template Haskell: P
{-# LANGUAGE TemplateHaskell, PatternSynonyms #-}
module T8759a where
foo = [d| pattern Q = False |]
T8759a.hs:5:7:
pattern synonyms not (yet) handled by Template Haskell
pattern Q = False
......@@ -317,3 +317,5 @@ test('T8577',
['T8577', '-v0 ' + config.ghc_th_way_flags])
test('T8633', normal, compile_and_run, [''])
test('T8625', normal, ghci_script, ['T8625.script'])
test('T8759', normal, compile_fail, ['-v0'])
test('T8759a', normal, compile_fail, ['-v0'])
\ No newline at end of file
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