Collect wildcards in sum types during renaming (#12711)
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Thu, 24 Nov 2016 01:12:17 +0000 (04:12 +0300)
committerÖmer Sinan Ağacan <omeragacan@gmail.com>
Thu, 24 Nov 2016 01:12:32 +0000 (04:12 +0300)
This patch also removes the "catch all" pattern in the function and
explicitly lists constructors to get a warning in the future if a new
`HsType` was added.

Reviewers: bgamari, austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12711

compiler/rename/RnTypes.hs
testsuite/tests/unboxedsums/T12711.script [new file with mode: 0644]
testsuite/tests/unboxedsums/T12711.stdout [new file with mode: 0644]
testsuite/tests/unboxedsums/all.T

index 56a0331..c548c4d 100644 (file)
@@ -1025,6 +1025,7 @@ collectAnonWildCards lty = go lty
       HsListTy ty                  -> go ty
       HsPArrTy ty                  -> go ty
       HsTupleTy _ tys              -> gos tys
+      HsSumTy tys                  -> gos tys
       HsOpTy ty1 _ ty2             -> go ty1 `mappend` go ty2
       HsParTy ty                   -> go ty
       HsIParamTy _ ty              -> go ty
@@ -1041,8 +1042,10 @@ collectAnonWildCards lty = go lty
       HsQualTy { hst_ctxt = L _ ctxt
                , hst_body = ty }  -> gos ctxt `mappend` go ty
       HsSpliceTy (HsSpliced _ (HsSplicedTy ty)) _ -> go $ L noSrcSpan ty
-      -- HsQuasiQuoteTy, HsSpliceTy, HsCoreTy, HsTyLit
-      _ -> mempty
+      HsSpliceTy{} -> mempty
+      HsCoreTy{} -> mempty
+      HsTyLit{} -> mempty
+      HsTyVar{} -> mempty
 
     gos = mconcat . map go
 
diff --git a/testsuite/tests/unboxedsums/T12711.script b/testsuite/tests/unboxedsums/T12711.script
new file mode 100644 (file)
index 0000000..898fdc1
--- /dev/null
@@ -0,0 +1,2 @@
+:set -XUnboxedSums
+:kind (# _ | _ #)
diff --git a/testsuite/tests/unboxedsums/T12711.stdout b/testsuite/tests/unboxedsums/T12711.stdout
new file mode 100644 (file)
index 0000000..13070df
--- /dev/null
@@ -0,0 +1 @@
+(# _ | _ #) :: TYPE 'GHC.Types.UnboxedSumRep
index ed41084..290ae43 100644 (file)
@@ -22,6 +22,7 @@ test('thunk', only_ways(['normal']), compile_and_run, [''])
 test('T12375', only_ways(['normal']), compile_and_run, [''])
 test('empty_sum', only_ways(['normal']), compile_and_run, [''])
 test('sum_rr', normal, compile_fail, [''])
+test('T12711', only_ways(['ghci']), ghci_script, ['T12711.script'])
 
 # TODO: Need to run this in --slow mode only
 # test('sum_api_annots',