Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Commit a7f64c6

Browse files
xnningbgamari
authored andcommitted
Fix TcType.anyRewritableTyVar
Summary: This patch fixes #15805, where we found that `TcType.anyRewritableTyVar` has one wrong case. Besides the fix, it also: - removed some unnecessary `ASSERT2(tcIsTcTyVar...)` in `TcType`, as now we have `tcIsTcTyVar = isTyVar`. - fixed some comments Test Plan: ./validate Reviewers: goldfire, simonpj, bgamari Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15805 Differential Revision: https://phabricator.haskell.org/D5263
1 parent 2f2308e commit a7f64c6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

compiler/typecheck/TcType.hs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pprTcTyVarDetails (MetaTv { mtv_info = info, mtv_tclvl = tclvl })
569569

570570
-------------------------------------
571571
-- UserTypeCtxt describes the origin of the polymorphic type
572-
-- in the places where we need to an expression has that type
572+
-- in the places where we need an expression to have that type
573573

574574
data UserTypeCtxt
575575
= FunSigCtxt -- Function type signature, when checking the type
@@ -708,7 +708,7 @@ Note [TcLevel and untouchable type variables]
708708
709709
* A unification variable is *touchable* if its level number
710710
is EQUAL TO that of its immediate parent implication,
711-
and it is a TauTv or TyVarTv (but /not/ FlatMetaTv or FlatSkolTv
711+
and it is a TauTv or TyVarTv (but /not/ FlatMetaTv or FlatSkolTv)
712712
713713
Note [WantedInv]
714714
~~~~~~~~~~~~~~~~
@@ -975,7 +975,7 @@ anyRewritableTyVar ignore_cos role pred ty
975975
go rl bvs (CoercionTy co) = go_co rl bvs co -- ToDo: check
976976

977977
go_tc NomEq bvs _ tys = any (go NomEq bvs) tys
978-
go_tc ReprEq bvs tc tys = foldr ((&&) . go_arg bvs) False $
978+
go_tc ReprEq bvs tc tys = any (go_arg bvs)
979979
(tyConRolesRepresentational tc `zip` tys)
980980

981981
go_arg bvs (Nominal, ty) = go NomEq bvs ty
@@ -1014,7 +1014,7 @@ out the other (Trac #14363).
10141014
********************************************************************* -}
10151015

10161016
data CandidatesQTvs -- See Note [Dependent type variables]
1017-
-- See Note [CandidatesQTvs determinism]
1017+
-- See Note [CandidatesQTvs determinism and order]
10181018
= DV { dv_kvs :: DTyCoVarSet -- "kind" variables (dependent)
10191019
, dv_tvs :: DTyVarSet -- "type" variables (non-dependent)
10201020
-- A variable may appear in both sets
@@ -1178,8 +1178,7 @@ isFloatedTouchableMetaTyVar ctxt_tclvl tv
11781178
| isTyVar tv -- See Note [Coercion variables in free variable lists]
11791179
, MetaTv { mtv_tclvl = tv_tclvl, mtv_info = info } <- tcTyVarDetails tv
11801180
, not (isFlattenInfo info)
1181-
= ASSERT2( tcIsTcTyVar tv, ppr tv )
1182-
tv_tclvl `strictlyDeeperThan` ctxt_tclvl
1181+
= tv_tclvl `strictlyDeeperThan` ctxt_tclvl
11831182

11841183
| otherwise = False
11851184

@@ -1195,8 +1194,7 @@ isTyConableTyVar tv
11951194
-- with a type constructor application; in particular,
11961195
-- not a TyVarTv
11971196
| isTyVar tv -- See Note [Coercion variables in free variable lists]
1198-
= ASSERT2( tcIsTcTyVar tv, ppr tv )
1199-
case tcTyVarDetails tv of
1197+
= case tcTyVarDetails tv of
12001198
MetaTv { mtv_info = TyVarTv } -> False
12011199
_ -> True
12021200
| otherwise = True
@@ -1213,7 +1211,7 @@ isFskTyVar tv
12131211
MetaTv { mtv_info = FlatSkolTv } -> True
12141212
_ -> False
12151213

1216-
-- | True of both given and wanted flatten-skolems (fak and usk)
1214+
-- | True of both given and wanted flatten-skolems (fmv and fsk)
12171215
isFlattenTyVar tv
12181216
= ASSERT2( tcIsTcTyVar tv, ppr tv )
12191217
case tcTyVarDetails tv of
@@ -1228,16 +1226,14 @@ isSkolemTyVar tv
12281226

12291227
isOverlappableTyVar tv
12301228
| isTyVar tv -- See Note [Coercion variables in free variable lists]
1231-
= ASSERT2( tcIsTcTyVar tv, ppr tv )
1232-
case tcTyVarDetails tv of
1229+
= case tcTyVarDetails tv of
12331230
SkolemTv _ overlappable -> overlappable
12341231
_ -> False
12351232
| otherwise = False
12361233

12371234
isMetaTyVar tv
12381235
| isTyVar tv -- See Note [Coercion variables in free variable lists]
1239-
= ASSERT2( tcIsTcTyVar tv, ppr tv )
1240-
case tcTyVarDetails tv of
1236+
= case tcTyVarDetails tv of
12411237
MetaTv {} -> True
12421238
_ -> False
12431239
| otherwise = False

0 commit comments

Comments
 (0)