[commit: ghc] master: Collect wildcards in sum types during renaming (#12711) (14ac372)
git at git.haskell.org
git at git.haskell.org
Thu Nov 24 01:13:38 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/14ac3725eb1e93289f205cbf432b537f6c84c4dc/ghc
>---------------------------------------------------------------
commit 14ac3725eb1e93289f205cbf432b537f6c84c4dc
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date: Thu Nov 24 04:12:17 2016 +0300
Collect wildcards in sum types during renaming (#12711)
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
>---------------------------------------------------------------
14ac3725eb1e93289f205cbf432b537f6c84c4dc
compiler/rename/RnTypes.hs | 7 +++++--
testsuite/tests/unboxedsums/T12711.script | 2 ++
testsuite/tests/unboxedsums/T12711.stdout | 1 +
testsuite/tests/unboxedsums/all.T | 1 +
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs
index 56a0331..c548c4d 100644
--- a/compiler/rename/RnTypes.hs
+++ b/compiler/rename/RnTypes.hs
@@ -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
index 0000000..898fdc1
--- /dev/null
+++ b/testsuite/tests/unboxedsums/T12711.script
@@ -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
index 0000000..13070df
--- /dev/null
+++ b/testsuite/tests/unboxedsums/T12711.stdout
@@ -0,0 +1 @@
+(# _ | _ #) :: TYPE 'GHC.Types.UnboxedSumRep
diff --git a/testsuite/tests/unboxedsums/all.T b/testsuite/tests/unboxedsums/all.T
index ed41084..290ae43 100644
--- a/testsuite/tests/unboxedsums/all.T
+++ b/testsuite/tests/unboxedsums/all.T
@@ -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',
More information about the ghc-commits
mailing list