summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-12-20 19:25:37 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2017-12-20 19:25:38 -0500
commit9cb289abc582c9eb8337a2621baf58e35feeff46 (patch)
tree873c348f3666bf35bb6e4e632c40ad6669a9de15
parent9caf40e9d7233a2a6e78a0c4f2d2f13acbf804dd (diff)
downloadhaskell-9cb289abc582c9eb8337a2621baf58e35feeff46.tar.gz
Remove hack put in place for #12512
Summary: Previously, I added an ad hoc check for unboxed tuples and sums in standalone-derived instances to fix #12512, under the pretense that polymorphism over `UnboxedTupleRep` and `UnboxedSumRep` was a lie. But that is no longer the case, and so this ad hoc check can be removed entirely. Less code, and easier to understand. Test Plan: make test TEST=T12512 Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4271
-rw-r--r--compiler/typecheck/TcDeriv.hs12
-rw-r--r--testsuite/tests/deriving/should_fail/T12512.stderr6
2 files changed, 5 insertions, 13 deletions
diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index 33ce5810ca..f0ddce04ca 100644
--- a/compiler/typecheck/TcDeriv.hs
+++ b/compiler/typecheck/TcDeriv.hs
@@ -638,12 +638,6 @@ deriveStandalone (L loc (DerivDecl deriv_ty deriv_strat' overlap_mode))
-> do warnUselessTypeable
return Nothing
- | isUnboxedTupleTyCon tc
- -> bale_out $ unboxedTyConErr "tuple"
-
- | isUnboxedSumTyCon tc
- -> bale_out $ unboxedTyConErr "sum"
-
| isAlgTyCon tc || isDataFamilyTyCon tc -- All other classes
-> do { spec <- mkEqnHelp (fmap unLoc overlap_mode)
tvs cls cls_tys tc tc_args
@@ -973,7 +967,7 @@ mkEqnHelp overlap_mode tvs cls cls_tys tycon tc_args mtheta deriv_strat
, denv_mtheta = mtheta
, denv_strat = deriv_strat }
; flip runReaderT deriv_env $
- if isDataTyCon rep_tc then mkDataTypeEqn else mkNewTypeEqn }
+ if isNewTyCon rep_tc then mkNewTypeEqn else mkDataTypeEqn }
where
bale_out msg = failWithTc (derivingThingErr False cls cls_tys
(mkTyConApp tycon tc_args) deriv_strat msg)
@@ -1932,7 +1926,3 @@ derivingHiddenErr tc
standaloneCtxt :: LHsSigType GhcRn -> SDoc
standaloneCtxt ty = hang (text "In the stand-alone deriving instance for")
2 (quotes (ppr ty))
-
-unboxedTyConErr :: String -> MsgDoc
-unboxedTyConErr thing =
- text "The last argument of the instance cannot be an unboxed" <+> text thing
diff --git a/testsuite/tests/deriving/should_fail/T12512.stderr b/testsuite/tests/deriving/should_fail/T12512.stderr
index a62cda6b99..78c49f4233 100644
--- a/testsuite/tests/deriving/should_fail/T12512.stderr
+++ b/testsuite/tests/deriving/should_fail/T12512.stderr
@@ -1,10 +1,12 @@
T12512.hs:10:1: error:
• Can't make a derived instance of ‘Wat1 (# a, b #)’:
- The last argument of the instance cannot be an unboxed tuple
+ ‘Wat1’ is not a stock derivable class (Eq, Show, etc.)
+ Try enabling DeriveAnyClass
• In the stand-alone deriving instance for ‘Wat1 (# a, b #)’
T12512.hs:13:1: error:
• Can't make a derived instance of ‘Wat2 (# a | b #)’:
- The last argument of the instance cannot be an unboxed sum
+ ‘Wat2’ is not a stock derivable class (Eq, Show, etc.)
+ Try enabling DeriveAnyClass
• In the stand-alone deriving instance for ‘Wat2 (# a | b #)’