[Git][ghc/ghc][wip/T16728] wibbles

Simon Peyton Jones gitlab at gitlab.haskell.org
Thu Jun 6 20:08:57 UTC 2019



Simon Peyton Jones pushed to branch wip/T16728 at Glasgow Haskell Compiler / GHC


Commits:
598efac5 by Simon Peyton Jones at 2019-06-06T20:03:38Z
wibbles

- - - - -


4 changed files:

- compiler/typecheck/TcCanonical.hs
- compiler/typecheck/TcHsType.hs
- compiler/typecheck/TcSigs.hs
- compiler/typecheck/TcType.hs


Changes:

=====================================
compiler/typecheck/TcCanonical.hs
=====================================
@@ -1008,6 +1008,8 @@ can_eq_nc_forall ev eq_rel s1 s2
                                                   (substTy subst (tyVarKind tv2))
                    ; let subst' = extendTvSubstAndInScope subst tv2
                                        (mkCastTy (mkTyVarTy skol_tv) kind_co)
+                         -- skol_tv is already in the in-scope set, but the
+                         -- free vars of kind_co are not; hence "...AndInScope"
                    ; (co, wanteds2) <- go skol_tvs subst' bndrs2
                    ; return ( mkTcForAllCo skol_tv kind_co co
                             , wanteds1 `unionBags` wanteds2 ) }


=====================================
compiler/typecheck/TcHsType.hs
=====================================
@@ -863,7 +863,7 @@ regardless of whether PartialTypeSignatures is enabled or not. But how would
 the typechecker know which '_' is being used in VKA and which is not when it
 calls emitNamedWildCardHoleConstraints in tcHsPartialSigType on all HsWildCardBndrs?
 The solution then is to neither rename nor include unnamed wildcards in HsWildCardBndrs,
-but instead give every anonymouswildcard a fresh wild tyvar in tcAnonWildCardOcc.
+but instead give every anonymous wildcard a fresh wild tyvar in tcAnonWildCardOcc.
 And whenever we see a '@', we automatically turn on PartialTypeSignatures and
 turn off hole constraint warnings, and do not call emitAnonWildCardHoleConstraint
 under these conditions.
@@ -1709,7 +1709,7 @@ To avoid the double-zonk, we do two things:
 tcNamedWildCardBinders :: [Name]
                        -> ([(Name, TcTyVar)] -> TcM a)
                        -> TcM a
--- Bring into scope the /named/ wildcard binders.  Remember taht
+-- Bring into scope the /named/ wildcard binders.  Remember that
 -- plain wildcards _ are anonymous and dealt with by HsWildCardTy
 -- Soe Note [The wildcard story for types] in HsTypes
 tcNamedWildCardBinders wc_names thing_inside
@@ -2477,8 +2477,8 @@ tcHsPartialSigType
   -> LHsSigWcType GhcRn       -- The type signature
   -> TcM ( [(Name, TcTyVar)]  -- Wildcards
          , Maybe TcType       -- Extra-constraints wildcard
-         , [Name]             -- Original tyvar names, in correspondence with ...
-         , [TcTyVar]          -- ... Implicitly and explicitly bound type variables
+         , [(Name,TcTyVar)]   -- Original tyvar names, in correspondence with
+                              --   the implicitly and explicitly bound type variables
          , TcThetaType        -- Theta part
          , TcType )           -- Tau part
 -- See Note [Checking partial type signatures]
@@ -2504,26 +2504,23 @@ tcHsPartialSigType ctxt sig_ty
 
                   ; return (wcs, wcx, theta, tau) }
 
-         -- We must return these separately, because all the zonking below
-         -- might change the name of a TyVarTv. This, in turn, causes trouble
-         -- in partial type signatures that bind scoped type variables, as
-         -- we bring the wrong name into scope in the function body.
-         -- Test case: partial-sigs/should_compile/LocalDefinitionBug
-       ; let tv_names = implicit_hs_tvs ++ hsLTyVarNames explicit_hs_tvs
-
        -- Spit out the wildcards (including the extra-constraints one)
        -- as "hole" constraints, so that they'll be reported if necessary
        -- See Note [Extra-constraint holes in partial type signatures]
        ; emitNamedWildCardHoleConstraints wcs
 
-       ; let all_tvs = implicit_tvs ++ explicit_tvs
+         -- We return a proper (Name,TyVar) environment, to be sure that
+         -- we bring the right name into scope in the function body.
+         -- Test case: partial-sigs/should_compile/LocalDefinitionBug
+       ; let tv_prs = (implicit_hs_tvs                  `zip` implicit_tvs)
+                      ++ (hsLTyVarNames explicit_hs_tvs `zip` explicit_tvs)
 
       -- NB: checkValidType on the final inferred type will be
       --     done later by checkInferredPolyId.  We can't do it
       --     here because we don't have a complete tuype to check
 
-       ; traceTc "tcHsPartialSigType" (ppr all_tvs)
-       ; return (wcs, wcx, tv_names, all_tvs, theta, tau) }
+       ; traceTc "tcHsPartialSigType" (ppr tv_prs)
+       ; return (wcs, wcx, tv_prs, theta, tau) }
 
 tcHsPartialSigType _ (HsWC _ (XHsImplicitBndrs _)) = panic "tcHsPartialSigType"
 tcHsPartialSigType _ (XHsWildCardBndrs _) = panic "tcHsPartialSigType"


=====================================
compiler/typecheck/TcSigs.hs
=====================================
@@ -498,10 +498,9 @@ tcInstSig hs_sig@(PartialSig { psig_hs_ty = hs_ty
                              , sig_loc = loc })
   = setSrcSpan loc $  -- Set the binding site of the tyvars
     do { traceTc "Staring partial sig {" (ppr hs_sig)
-       ; (wcs, wcx, tv_names, tvs, theta, tau) <- tcHsPartialSigType ctxt hs_ty
+       ; (wcs, wcx, tv_prs, theta, tau) <- tcHsPartialSigType ctxt hs_ty
          -- See Note [Checking partial type signatures] in TcHsType
-       ; let tv_prs = tv_names `zip` tvs
-             inst_sig = TISI { sig_inst_sig   = hs_sig
+       ; let inst_sig = TISI { sig_inst_sig   = hs_sig
                              , sig_inst_skols = tv_prs
                              , sig_inst_wcs   = wcs
                              , sig_inst_wcx   = wcx


=====================================
compiler/typecheck/TcType.hs
=====================================
@@ -1794,8 +1794,8 @@ hasTyVarHead ty                 -- Haskell 98 allows predicates of form
 
 evVarPred :: EvVar -> PredType
 evVarPred var = varType var
-  -- Historical note: I used to have an ASSERRT here,
-  -- checking (isEvVarType (varType var).  But with something like
+  -- Historical note: I used to have an ASSERT here,
+  -- checking (isEvVarType (varType var)).  But with something like
   --   f :: c => _ -> _
   -- we end up with (c :: kappa), and (kappa ~ Constraint).  Until
   -- we solve and zonk (which there is no particular reason to do for



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/598efac59cde44706761048aeb47e624da1f5b22

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/598efac59cde44706761048aeb47e624da1f5b22
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190606/ad7e4f78/attachment-0001.html>


More information about the ghc-commits mailing list