
Simon Peyton Jones pushed to branch wip/T26115 at Glasgow Haskell Compiler / GHC Commits: e5017601 by Simon Peyton Jones at 2025-06-21T22:56:35+01:00 Restore the missing overlap checking in one-shot solving I have done this by re-using TcSSpecPrag mode, which is a bit of a hack. Certainly need docs. - - - - - 3 changed files: - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Validity.hs Changes: ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -767,6 +767,7 @@ tryShortCutSolver try_short_cut dict_w@(DictCt { di_ev = ev_w }) -- Enabled by the -fsolve-constant-dicts flag -> tryTcS $ -- tryTcS tries to completely solve some contraints + setTcSMode TcSSpecPrag $ do { updInertSet zap_cans ; solveSimpleWanteds (unitBag (CDictCan dict_w)) } @@ -899,7 +900,7 @@ matchClassInst dflags inerts clas tys loc ; return local_res } NoInstance -- No local instances, so try global ones - -> do { global_res <- matchGlobalInst dflags False clas tys loc + -> do { global_res <- matchGlobalInst dflags clas tys loc ; warn_custom_warn_instance global_res loc -- See Note [Implementation of deprecated instances] ; traceTcS "} matchClassInst global result" $ ppr global_res ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -2020,12 +2020,11 @@ instFlexiXTcM subst (tv:tvs) subst' = extendTvSubstWithClone subst tv tv' ; instFlexiXTcM subst' tvs } -matchGlobalInst :: DynFlags - -> Bool -- True <=> caller is the short-cut solver - -- See Note [Shortcut solving: overlap] - -> Class -> [Type] -> CtLoc -> TcS TcM.ClsInstResult -matchGlobalInst dflags short_cut cls tys loc - = wrapTcS $ TcM.matchGlobalInst dflags short_cut cls tys (Just loc) +matchGlobalInst :: DynFlags -> Class -> [Type] -> CtLoc -> TcS TcM.ClsInstResult +matchGlobalInst dflags cls tys loc + = do { mode <- getTcSMode + ; let short_cut = mode == TcSSpecPrag + ; wrapTcS $ TcM.matchGlobalInst dflags short_cut cls tys (Just loc) } tcInstSkolTyVarsX :: SkolemInfo -> Subst -> [TyVar] -> TcS (Subst, [TcTyVar]) tcInstSkolTyVarsX skol_info subst tvs = wrapTcS $ TcM.tcInstSkolTyVarsX skol_info subst tvs ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -26,13 +26,13 @@ import GHC.Data.Maybe import GHC.Tc.Utils.Unify ( tcSubTypeAmbiguity ) import GHC.Tc.Solver ( simplifyAmbiguityCheck ) import GHC.Tc.Instance.Class ( matchGlobalInst, ClsInstResult(..), AssocInstInfo(..) ) -import GHC.Tc.Utils.TcType +import GHC.Tc.Instance.FunDeps +import GHC.Tc.Instance.Family import GHC.Tc.Types.Origin import GHC.Tc.Types.Rank import GHC.Tc.Errors.Types +import GHC.Tc.Utils.TcType import GHC.Tc.Utils.Monad -import GHC.Tc.Instance.FunDeps -import GHC.Tc.Instance.Family import GHC.Tc.Zonk.TcType import GHC.Builtin.Types View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e50176014c7484861ed3ba63e8b3359f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e50176014c7484861ed3ba63e8b3359f... You're receiving this email because of your account on gitlab.haskell.org.