diff options
-rw-r--r-- | compiler/GHC/ThToHs.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/th/T17379a.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/th/T17379a.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/th/T17379b.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/th/T17379b.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 2 |
6 files changed, 32 insertions, 0 deletions
diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs index 29f7b1e139..7df5aee397 100644 --- a/compiler/GHC/ThToHs.hs +++ b/compiler/GHC/ThToHs.hs @@ -600,6 +600,9 @@ cvtConstr (ForallC tvs ctxt con) add_forall _ _ (XConDecl nec) = noExtCon nec +cvtConstr (GadtC [] _strtys _ty) + = failWith (text "GadtC must have at least one constructor name") + cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys @@ -607,6 +610,9 @@ cvtConstr (GadtC c strtys ty) ; c_ty <- mk_arr_apps args ty' ; returnL $ fst $ mkGadtDecl c' c_ty} +cvtConstr (RecGadtC [] _varstrtys _ty) + = failWith (text "RecGadtC must have at least one constructor name") + cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty diff --git a/testsuite/tests/th/T17379a.hs b/testsuite/tests/th/T17379a.hs new file mode 100644 index 0000000000..66702bb9b8 --- /dev/null +++ b/testsuite/tests/th/T17379a.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE GADTSyntax #-} + +module T17379a where + +import Language.Haskell.TH + +$(let typ = mkName "T" in pure [ DataD [] typ [] Nothing [GadtC [] [] (ConT typ)] [] ]) diff --git a/testsuite/tests/th/T17379a.stderr b/testsuite/tests/th/T17379a.stderr new file mode 100644 index 0000000000..ec98c5fb54 --- /dev/null +++ b/testsuite/tests/th/T17379a.stderr @@ -0,0 +1,4 @@ + +T17379a.hs:8:3: + GadtC must have at least one constructor name + When splicing a TH declaration: data T where :: T diff --git a/testsuite/tests/th/T17379b.hs b/testsuite/tests/th/T17379b.hs new file mode 100644 index 0000000000..c83d180d18 --- /dev/null +++ b/testsuite/tests/th/T17379b.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE GADTSyntax #-} + +module T17379b where + +import Language.Haskell.TH + +$(let typ = mkName "T" in pure [ DataD [] typ [] Nothing [RecGadtC [] [] (ConT typ)] [] ]) diff --git a/testsuite/tests/th/T17379b.stderr b/testsuite/tests/th/T17379b.stderr new file mode 100644 index 0000000000..47410ecdd0 --- /dev/null +++ b/testsuite/tests/th/T17379b.stderr @@ -0,0 +1,4 @@ + +T17379b.hs:8:3: + RecGadtC must have at least one constructor name + When splicing a TH declaration: data T where :: {} -> T diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 986be55ba1..2a54cc9956 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -487,3 +487,5 @@ test('T16980', normal, compile, ['']) test('T16980a', normal, compile_fail, ['']) test('T17296', normal, compile, ['-v0']) test('T17394', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) +test('T17379a', normal, compile_fail, ['']) +test('T17379b', normal, compile_fail, ['']) |