summaryrefslogtreecommitdiff
path: root/compiler/iface
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2019-11-22 20:12:07 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-12-16 19:31:44 -0500
commit75355fdef61da44a395ee9bfa2b9dca0eecea58a (patch)
tree93731c2483e5886c4dd9344e39ff81110ef5bdd8 /compiler/iface
parent3e17a866fecebc5f80b4e7da93a73803b86499ca (diff)
downloadhaskell-75355fdef61da44a395ee9bfa2b9dca0eecea58a.tar.gz
Use "OrCoVar" functions less
As described in #17291, we'd like to separate coercions and expressions in a more robust fashion. This is a small step in this direction. - `mkLocalId` now panicks on a covar. Calls where this was not the case were changed to `mkLocalIdOrCoVar`. - Don't use "OrCoVar" functions in places where we know the type is not a coercion.
Diffstat (limited to 'compiler/iface')
-rw-r--r--compiler/iface/TcIface.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/iface/TcIface.hs b/compiler/iface/TcIface.hs
index 1e9fe4fbfa..4cc9195045 100644
--- a/compiler/iface/TcIface.hs
+++ b/compiler/iface/TcIface.hs
@@ -1321,6 +1321,8 @@ tcIfaceExpr (IfaceCase scrut case_bndr alts) = do
let
scrut_ty = exprType scrut'
case_bndr' = mkLocalIdOrCoVar case_bndr_name scrut_ty
+ -- "OrCoVar" since a coercion can be a scrutinee with -fdefer-type-errors
+ -- (e.g. see test T15695). Ticket #17291 covers fixing this problem.
tc_app = splitTyConApp scrut_ty
-- NB: Won't always succeed (polymorphic case)
-- but won't be demanded in those cases
@@ -1337,7 +1339,7 @@ tcIfaceExpr (IfaceLet (IfaceNonRec (IfLetBndr fs ty info ji) rhs) body)
; ty' <- tcIfaceType ty
; id_info <- tcIdInfo False {- Don't ignore prags; we are inside one! -}
NotTopLevel name ty' info
- ; let id = mkLocalIdOrCoVarWithInfo name ty' id_info
+ ; let id = mkLocalIdWithInfo name ty' id_info
`asJoinId_maybe` tcJoinInfo ji
; rhs' <- tcIfaceExpr rhs
; body' <- extendIfaceIdEnv [id] (tcIfaceExpr body)
@@ -1353,7 +1355,7 @@ tcIfaceExpr (IfaceLet (IfaceRec pairs) body)
tc_rec_bndr (IfLetBndr fs ty _ ji)
= do { name <- newIfaceName (mkVarOccFS fs)
; ty' <- tcIfaceType ty
- ; return (mkLocalIdOrCoVar name ty' `asJoinId_maybe` tcJoinInfo ji) }
+ ; return (mkLocalId name ty' `asJoinId_maybe` tcJoinInfo ji) }
tc_pair (IfLetBndr _ _ info _, rhs) id
= do { rhs' <- tcIfaceExpr rhs
; id_info <- tcIdInfo False {- Don't ignore prags; we are inside one! -}
@@ -1733,6 +1735,7 @@ bindIfaceId (fs, ty) thing_inside
= do { name <- newIfaceName (mkVarOccFS fs)
; ty' <- tcIfaceType ty
; let id = mkLocalIdOrCoVar name ty'
+ -- We should not have "OrCoVar" here, this is a bug (#17545)
; extendIfaceIdEnv [id] (thing_inside id) }
bindIfaceIds :: [IfaceIdBndr] -> ([Id] -> IfL a) -> IfL a