summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2018-05-13 11:41:16 -0400
committerBen Gamari <ben@smart-cactus.org>2018-05-13 18:30:43 -0400
commitf0212a93a2f3d4fb564c1025cca0dfd3050487e4 (patch)
tree3ad34bf74f470eda61e8f42c8102c425a7c3db28 /compiler
parent9039f847a568ac69436d449b9fe090ecd03b9e06 (diff)
downloadhaskell-f0212a93a2f3d4fb564c1025cca0dfd3050487e4.tar.gz
TcInteract: Ensure that tycons have representations before solving for Typeable
Summary: This fixes #15067. Test Plan: Validate Subscribers: thomie, carter, RyanGlScott GHC Trac Issues: #15067 Differential Revision: https://phabricator.haskell.org/D4623
Diffstat (limited to 'compiler')
-rw-r--r--compiler/basicTypes/DataCon.hs-boot1
-rw-r--r--compiler/typecheck/TcInteract.hs3
-rw-r--r--compiler/types/TyCon.hs6
3 files changed, 9 insertions, 1 deletions
diff --git a/compiler/basicTypes/DataCon.hs-boot b/compiler/basicTypes/DataCon.hs-boot
index 841f8c9d1c..61fb3ce15d 100644
--- a/compiler/basicTypes/DataCon.hs-boot
+++ b/compiler/basicTypes/DataCon.hs-boot
@@ -25,6 +25,7 @@ dataConInstOrigArgTys :: DataCon -> [Type] -> [Type]
dataConStupidTheta :: DataCon -> ThetaType
dataConFullSig :: DataCon
-> ([TyVar], [TyVar], [EqSpec], ThetaType, [Type], Type)
+isUnboxedSumCon :: DataCon -> Bool
instance Eq DataCon
instance Uniquable DataCon
diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs
index 377b2d6c32..41afe3fdd7 100644
--- a/compiler/typecheck/TcInteract.hs
+++ b/compiler/typecheck/TcInteract.hs
@@ -2698,9 +2698,12 @@ doFunTy clas ty arg_ty ret_ty
-- of monomorphic kind (e.g. all kind variables have been instantiated).
doTyConApp :: Class -> Type -> TyCon -> [Kind] -> TcS LookupInstResult
doTyConApp clas ty tc kind_args
+ | Just _ <- tyConRepName_maybe tc
= return $ GenInst (map (mk_typeable_pred clas) kind_args)
(\kinds -> evTypeable ty $ EvTypeableTyCon tc (map EvExpr kinds))
True
+ | otherwise
+ = return NoInstance
-- | Representation for TyCon applications of a concrete kind. We just use the
-- kind itself, but first we must make sure that we've instantiated all kind-
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index 67c7b1b6a7..5717aef9b8 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -155,6 +155,7 @@ import Util
import Unique( tyConRepNameUnique, dataConRepNameUnique )
import UniqSet
import Module
+import {-# SOURCE #-} DataCon
import qualified Data.Data as Data
@@ -1190,7 +1191,10 @@ tyConRepName_maybe (AlgTyCon { algTcParent = parent })
| UnboxedAlgTyCon rep_nm <- parent = rep_nm
tyConRepName_maybe (FamilyTyCon { famTcFlav = DataFamilyTyCon rep_nm })
= Just rep_nm
-tyConRepName_maybe (PromotedDataCon { tcRepName = rep_nm })
+tyConRepName_maybe (PromotedDataCon { dataCon = dc, tcRepName = rep_nm })
+ | isUnboxedSumCon dc -- see #13276
+ = Nothing
+ | otherwise
= Just rep_nm
tyConRepName_maybe _ = Nothing