diff options
26 files changed, 742 insertions, 132 deletions
diff --git a/compiler/typecheck/TcEnv.hs b/compiler/typecheck/TcEnv.hs index 79ba7c51b7..e8ddd0702d 100644 --- a/compiler/typecheck/TcEnv.hs +++ b/compiler/typecheck/TcEnv.hs @@ -34,7 +34,7 @@ module TcEnv( isTypeClosedLetBndr, tcLookup, tcLookupLocated, tcLookupLocalIds, - tcLookupId, tcLookupTyVar, + tcLookupId, tcLookupIdMaybe, tcLookupTyVar, tcLookupLcl_maybe, getInLocalScope, wrongThingErr, pprBinders, @@ -352,11 +352,18 @@ tcLookupId :: Name -> TcM Id -- -- The Id is never a DataCon. (Why does that matter? see TcExpr.tcId) tcLookupId name = do - thing <- tcLookup name + thing <- tcLookupIdMaybe name case thing of - ATcId { tct_id = id} -> return id - AGlobal (AnId id) -> return id - _ -> pprPanic "tcLookupId" (ppr name) + Just id -> return id + _ -> pprPanic "tcLookupId" (ppr name) + +tcLookupIdMaybe :: Name -> TcM (Maybe Id) +tcLookupIdMaybe name + = do { thing <- tcLookup name + ; case thing of + ATcId { tct_id = id} -> return $ Just id + AGlobal (AnId id) -> return $ Just id + _ -> return Nothing } tcLookupLocalIds :: [Name] -> TcM [TcId] -- We expect the variables to all be bound, and all at diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs index d7c97145b8..795c3e5186 100644 --- a/compiler/typecheck/TcErrors.hs +++ b/compiler/typecheck/TcErrors.hs @@ -46,10 +46,10 @@ import NameSet import Bag import ErrUtils ( ErrMsg, errDoc, pprLocErrMsg ) import BasicTypes -import ConLike ( ConLike(..), conLikeWrapId_maybe ) +import ConLike ( ConLike(..)) import Util -import HscTypes (HscEnv, lookupTypeHscEnv, TypeEnv, lookupTypeEnv ) -import NameEnv (lookupNameEnv) +import TcEnv (tcLookupIdMaybe) +import {-# SOURCE #-} TcSimplify ( tcSubsumes ) import FastString import Outputable import SrcLoc @@ -62,7 +62,7 @@ import FV ( fvVarList, unionFV ) import Control.Monad ( when ) import Data.Foldable ( toList ) -import Data.List ( partition, mapAccumL, nub, sortBy, unfoldr ) +import Data.List ( partition, mapAccumL, nub, sortBy, unfoldr, foldl') import qualified Data.Set as Set import Data.Semigroup ( Semigroup ) @@ -1076,7 +1076,7 @@ mkHoleError ctxt ct@(CHoleCan { cc_hole = hole }) = givenConstraintsMsg ctxt | otherwise = empty - ; sub_msg <- validSubstitutions ct + ; sub_msg <- validSubstitutions ctxt ct ; mkErrorMsgFromCt ctxt ct $ important hole_msg `mappend` relevant_bindings (binds_msg $$ constraints_msg) `mappend` @@ -1128,26 +1128,37 @@ mkHoleError _ ct = pprPanic "mkHoleError" (ppr ct) -- See Note [Valid substitutions include ...] -validSubstitutions :: Ct -> TcM SDoc -validSubstitutions ct | isExprHoleCt ct = - do { top_env <- getTopEnv - ; rdr_env <- getGlobalRdrEnv - ; gbl_env <- tcg_type_env <$> getGblEnv - ; lcl_env <- getLclTypeEnv +validSubstitutions :: ReportErrCtxt -> Ct -> TcM SDoc +validSubstitutions (CEC {cec_encl = implics}) ct | isExprHoleCt ct = + do { rdr_env <- getGlobalRdrEnv ; dflags <- getDynFlags + ; traceTc "findingValidSubstitutionsFor {" $ ppr wrapped_hole_ty ; (discards, substitutions) <- - go (gbl_env, lcl_env, top_env) (maxValidSubstitutions dflags) - $ localsFirst $ globalRdrEnvElts rdr_env + setTcLevel hole_lvl $ + go (maxValidSubstitutions dflags) $ + localsFirst $ globalRdrEnvElts rdr_env + ; traceTc "}" empty ; return $ ppUnless (null substitutions) $ hang (text "Valid substitutions include") 2 (vcat (map (ppr_sub rdr_env) substitutions) $$ ppWhen discards subsDiscardMsg) } where + -- We extract the type of the hole from the constraint. hole_ty :: TcPredType hole_ty = ctEvPred (ctEvidence ct) + hole_loc = ctEvLoc $ ctEvidence ct + hole_env = ctLocEnv $ hole_loc + hole_lvl = ctLocLevel $ hole_loc - hole_env = ctLocEnv $ ctEvLoc $ ctEvidence ct + -- For checking, we wrap the type of the hole with all the givens + -- from all the implications in the context. + wrapped_hole_ty :: TcSigmaType + wrapped_hole_ty = foldl' wrapType hole_ty implics + + + -- We rearrange the elements to make locals appear at the top of the list, + -- since they're most likely to be relevant to the user localsFirst :: [GlobalRdrElt] -> [GlobalRdrElt] localsFirst elts = lcl ++ gbl where (lcl, gbl) = partition gre_lcl elts @@ -1157,12 +1168,19 @@ validSubstitutions ct | isExprHoleCt ct = is_id_bind (TcIdBndr_ExpType {}) = True is_id_bind (TcTvBndr {}) = False - relBindSet = mkOccSet $ [ occName b | b <- tcl_bndrs hole_env - , is_id_bind b ] + -- The set of relevant bindings. We use it to make sure we don't repeat + -- ids from the relevant bindings again in the suggestions. + relBindSet :: OccSet + relBindSet = mkOccSet [ occName b | b <- tcl_bndrs hole_env + , is_id_bind b ] + -- We skip elements that are already in the "Relevant Bindings Include" + -- part of the error message, as given by the relBindSet. shouldBeSkipped :: GlobalRdrElt -> Bool shouldBeSkipped el = (occName $ gre_name el) `elemOccSet` relBindSet + -- For pretty printing, we look up the name and type of the substitution + -- we found. ppr_sub :: GlobalRdrEnv -> Id -> SDoc ppr_sub rdr_env id = case lookupGRE_Name rdr_env (idName id) of Just elt -> sep [ idAndTy, nest 2 (parens $ pprNameProvenance elt)] @@ -1171,54 +1189,37 @@ validSubstitutions ct | isExprHoleCt ct = ty = varType id idAndTy = (pprPrefixOcc name <+> dcolon <+> pprType ty) - tyToId :: TyThing -> Maybe Id - tyToId (AnId i) = Just i - tyToId (AConLike c) = conLikeWrapId_maybe c - tyToId _ = Nothing - - tcTyToId :: TcTyThing -> Maybe Id - tcTyToId (AGlobal id) = tyToId id - tcTyToId (ATcId id _) = Just id - tcTyToId _ = Nothing - - substituteable :: Id -> Bool - substituteable = tcEqType hole_ty . varType + -- The real work happens here, where we invoke the typechecker to check + -- whether we the given type fits into the hole! + substituteable :: Id -> TcM Bool + substituteable id = wrapped_hole_ty `tcSubsumes` ty + where ty = varType id - lookupTopId :: HscEnv -> Name -> IO (Maybe Id) - lookupTopId env name = - maybe Nothing tyToId <$> lookupTypeHscEnv env name - - lookupGblId :: TypeEnv -> Name -> Maybe Id - lookupGblId env name = maybe Nothing tyToId $ lookupTypeEnv env name + -- Kickoff the checking of the elements. The first argument + -- is a counter, so that we stop after finding functions up to the + -- limit the user gives us. + go :: Maybe Int -> [GlobalRdrElt] -> TcM (Bool, [Id]) + go = go_ [] - lookupLclId :: TcTypeEnv -> Name -> Maybe Id - lookupLclId env name = maybe Nothing tcTyToId $ lookupNameEnv env name + -- We iterate over the elements, checking each one in turn. If we've + -- already found -fmax-valid-substitutions=n elements, we look no further. + go_ :: [Id] -> Maybe Int -> [GlobalRdrElt] -> TcM (Bool, [Id]) + go_ subs _ [] = return (False, reverse subs) + go_ subs (Just 0) _ = return (True, reverse subs) + go_ subs maxleft (el:elts) = + if shouldBeSkipped el then discard_it + else do { maybeId <- tcLookupIdMaybe (gre_name el) + ; case maybeId of + Just id -> do { canSub <- substituteable id + ; if canSub then (keep_it id) else discard_it } + _ -> discard_it + } + where discard_it = go_ subs maxleft elts + keep_it id = go_ (id:subs) ((\n -> n - 1) <$> maxleft) elts - go :: (TypeEnv, TcTypeEnv, HscEnv) -> Maybe Int -> [GlobalRdrElt] - -> TcM (Bool, [Id]) - go = go_ [] - go_ :: [Id] -> (TypeEnv, TcTypeEnv, HscEnv) -> Maybe Int -> [GlobalRdrElt] - -> TcM (Bool, [Id]) - go_ subs _ _ [] = return (False, reverse subs) - go_ subs _ (Just 0) _ = return (True, reverse subs) - go_ subs envs@(gbl,lcl,top) maxleft (el:elts) = - if shouldBeSkipped el then discard_it - else do { maybeId <- liftIO lookupId - ; case maybeId of - Just id | substituteable id -> - go_ (id:subs) envs ((\n -> n - 1) <$> maxleft) elts - _ -> discard_it } - where name = gre_name el - discard_it = go_ subs envs maxleft elts - getTopId = lookupTopId top name - gbl_id = lookupGblId gbl name - lcl_id = lookupLclId lcl name - lookupId = if (isJust lcl_id) then return lcl_id - else if (isJust gbl_id) then return gbl_id else getTopId - - -validSubstitutions _ = return empty +-- We don't (as of yet) handle holes in types, only in expressions. +validSubstitutions _ _ = return empty -- See Note [Constraints include ...] @@ -1265,39 +1266,55 @@ Note [Valid substitutions include ...] `validSubstitutions` returns the "Valid substitutions include ..." message. For example, look at the following definitions in a file called test.hs: - ps :: String -> IO () - ps = putStrLn - - ps2 :: a -> IO () - ps2 _ = putStrLn "hello, world" - - main :: IO () - main = _ "hello, world" - -The hole in `main` would generate the message: - - Valid substitutions include - ps :: String -> IO () ((defined at test.hs:2:1) - putStrLn :: String -> IO () - (imported from ‘Prelude’ at test.hs:1:1 - (and originally defined in ‘System.IO’)) - putStr :: String -> IO () - (imported from ‘Prelude’ at test.hs:1:1 - (and originally defined in ‘System.IO’)) - -Valid substitutions are found by checking names in scope. - -Currently the implementation only looks at exact type matches, as given by -`tcEqType`, so we DO NOT report `ps2` as a valid substitution in the example, -even though it fits in the hole. To determine that `ps2` fits in the hole, -we would need to check ids for subsumption, i.e. that the type of the hole is -a subtype of the id. This can be done using `tcSubType` from `TcUnify` and -`tcCheckSatisfiability` in `TcSimplify`. Unfortunately, `TcSimplify` uses -`TcErrors` to report errors found during constraint checking, so checking for -subsumption in holes would involve shuffling some code around in `TcSimplify`, -to make a non-error reporting constraint satisfiability checker which could -then be used for checking whether a given id satisfies the constraints imposed -by the hole. + import Data.List (inits) + + f :: [String] + f = _ "hello, world" + +The hole in `f` would generate the message: + + Valid substitutions include + inits :: forall a. [a] -> [[a]] + (imported from ‘Data.List’ at tp.hs:3:19-23 + (and originally defined in ‘base-4.10.0.0:Data.OldList’)) + fail :: forall (m :: * -> *). Monad m => forall a. String -> m a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Base’)) + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Base’)) + pure :: forall (f :: * -> *). Applicative f => forall a. a -> f a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Base’)) + return :: forall (m :: * -> *). Monad m => forall a. a -> m a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Base’)) + read :: forall a. Read a => String -> a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘Text.Read’)) + lines :: String -> [String] + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘base-4.10.0.0:Data.OldList’)) + words :: String -> [String] + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘base-4.10.0.0:Data.OldList’)) + error :: forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => [Char] -> a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Err’)) + errorWithoutStackTrace :: forall (a :: TYPE r). [Char] -> a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Err’)) + undefined :: forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => a + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.Err’)) + repeat :: forall a. a -> [a] + (imported from ‘Prelude’ at tp.hs:1:8-9 + (and originally defined in ‘GHC.List’)) + +Valid substitutions are found by checking top level ids in scope, and checking +whether their type subsumes the type of the hole. We remove ids that are +local bindings, since they are already included in the relevant bindings +section of the hole error message. Note [Constraints include ...] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index 1ae809fd99..a29ad92f18 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -102,6 +102,7 @@ module TcRnTypes( pprCtOrigin, pprCtLoc, pushErrCtxt, pushErrCtxtSameOrigin, + SkolemInfo(..), pprSigSkolInfo, pprSkolInfo, termEvidenceAllowed, @@ -110,6 +111,8 @@ module TcRnTypes( isWanted, isGiven, isDerived, isGivenOrWDeriv, ctEvRole, + wrapType, + -- Constraint solver plugins TcPlugin(..), TcPluginResult(..), TcPluginSolver, TcPluginM, runTcPluginM, unsafeTcPluginTcM, @@ -2484,6 +2487,18 @@ pprEvVarTheta ev_vars = pprTheta (map evVarPred ev_vars) pprEvVarWithType :: EvVar -> SDoc pprEvVarWithType v = ppr v <+> dcolon <+> pprType (evVarPred v) + + +-- | Wraps the given type with the constraints (via ic_given) in the given +-- implication, according to the variables mentioned (via ic_skols) +-- in the implication. +wrapType :: Type -> Implication -> Type +wrapType ty (Implic {ic_skols = skols, ic_given=givens}) = + wrapWithAllSkols $ mkFunTys (map idType givens) $ ty + where forAllTy :: Type -> TyVar -> Type + forAllTy ty tv = mkForAllTy tv Specified ty + wrapWithAllSkols ty = foldl forAllTy ty skols + {- ************************************************************************ * * diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs index 37cc77c422..943c596688 100644 --- a/compiler/typecheck/TcSimplify.hs +++ b/compiler/typecheck/TcSimplify.hs @@ -9,6 +9,7 @@ module TcSimplify( simplifyInteractive, solveEqualities, simplifyWantedsTcM, tcCheckSatisfiability, + tcSubsumes, -- For Rules we need these solveWanteds, solveWantedsAndDrop, @@ -44,6 +45,7 @@ import TrieMap () -- DV: for now import Type import TysWiredIn ( liftedRepTy ) import Unify ( tcMatchTyKi ) +import TcUnify ( tcSubType_NC ) import Util import Var import VarSet @@ -481,6 +483,24 @@ simplifyDefault theta ; traceTc "reportUnsolved }" empty ; return () } +-- | Reports whether first type (ty_a) subsumes the second type (ty_b), +-- discarding any errors. Subsumption here means that the ty_b can fit into the +-- ty_a, i.e. `tcSubsumes a b == True` if b is a subtype of a. +-- N.B.: Make sure that the types contain all the constraints +-- contained in any associated implications. +tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool +tcSubsumes ty_a ty_b | ty_a `eqType` ty_b = return True +tcSubsumes ty_a ty_b = discardErrs $ + do { (_, wanted, _) <- pushLevelAndCaptureConstraints $ + tcSubType_NC ExprSigCtxt ty_b ty_a + ; (rem, _) <- runTcS (simpl_top wanted) + -- We don't want any insoluble or simple constraints left, + -- but solved implications are ok (and neccessary for e.g. undefined) + ; return (isEmptyBag (wc_simple rem) + && isEmptyBag (wc_insol rem) + && allBag (isSolvedStatus . ic_status) (wc_impl rem)) + } + ------------------ tcCheckSatisfiability :: Bag EvVar -> TcM Bool -- Return True if satisfiable, False if definitely contradictory diff --git a/compiler/typecheck/TcSimplify.hs-boot b/compiler/typecheck/TcSimplify.hs-boot new file mode 100644 index 0000000000..a131bb3e82 --- /dev/null +++ b/compiler/typecheck/TcSimplify.hs-boot @@ -0,0 +1,9 @@ +module TcSimplify where + +import GhcPrelude +import TcRnTypes ( TcM ) +import TcType ( TcSigmaType ) + +-- This boot file exists solely to make tcSubsume avaialble in TcErrors + +tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool diff --git a/testsuite/tests/gadt/T12468.stderr b/testsuite/tests/gadt/T12468.stderr index 729b5c45b0..6585f663d0 100644 --- a/testsuite/tests/gadt/T12468.stderr +++ b/testsuite/tests/gadt/T12468.stderr @@ -4,3 +4,15 @@ T12468.hs:9:7: error: • In the expression: _ In an equation for ‘f’: f I = _ • Relevant bindings include f :: T a -> a (bound at T12468.hs:9:1) + Valid substitutions include + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at T12468.hs:3:8-13 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at T12468.hs:3:8-13 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T12468.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/ghci/scripts/T10248.stderr b/testsuite/tests/ghci/scripts/T10248.stderr index 9de7323928..e1ca96c63f 100644 --- a/testsuite/tests/ghci/scripts/T10248.stderr +++ b/testsuite/tests/ghci/scripts/T10248.stderr @@ -12,3 +12,8 @@ In an equation for ‘it’: it = Just <$> _ • Relevant bindings include it :: f (Maybe a) (bound at <interactive>:2:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/ghci/scripts/T10249.stderr b/testsuite/tests/ghci/scripts/T10249.stderr index ade995051e..e5eb289fbb 100644 --- a/testsuite/tests/ghci/scripts/T10249.stderr +++ b/testsuite/tests/ghci/scripts/T10249.stderr @@ -6,3 +6,8 @@ • In the expression: _ In an equation for ‘it’: it = _ • Relevant bindings include it :: t (bound at <interactive>:1:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/ghci/scripts/T8353.stderr b/testsuite/tests/ghci/scripts/T8353.stderr index 863a64fc4e..766fc1eb62 100644 --- a/testsuite/tests/ghci/scripts/T8353.stderr +++ b/testsuite/tests/ghci/scripts/T8353.stderr @@ -9,7 +9,19 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)] • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: Int (bound at Defer03.hs:7:1) - Valid substitutions include a :: Int (defined at Defer03.hs:4:1) + Valid substitutions include + a :: Int (defined at Defer03.hs:4:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Err’)) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) Defer03.hs:4:5: error: • Couldn't match expected type ‘Int’ with actual type ‘Char’ @@ -21,7 +33,19 @@ Defer03.hs:7:5: error: • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: Int (bound at Defer03.hs:7:1) - Valid substitutions include a :: Int (defined at Defer03.hs:4:1) + Valid substitutions include + a :: Int (defined at Defer03.hs:4:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Err’)) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) Defer03.hs:4:5: warning: [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Int’ with actual type ‘Char’ @@ -33,7 +57,19 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)] • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: Int (bound at Defer03.hs:7:1) - Valid substitutions include a :: Int (defined at Defer03.hs:4:1) + Valid substitutions include + a :: Int (defined at Defer03.hs:4:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Err’)) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) Defer03.hs:4:5: error: • Couldn't match expected type ‘Int’ with actual type ‘Char’ @@ -45,7 +81,19 @@ Defer03.hs:7:5: error: • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: Int (bound at Defer03.hs:7:1) - Valid substitutions include a :: Int (defined at Defer03.hs:4:1) + Valid substitutions include + a :: Int (defined at Defer03.hs:4:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Err’)) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) Defer03.hs:4:5: warning: [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Int’ with actual type ‘Char’ @@ -57,4 +105,16 @@ Defer03.hs:7:5: warning: [-Wtyped-holes (in -Wdefault)] • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: Int (bound at Defer03.hs:7:1) - Valid substitutions include a :: Int (defined at Defer03.hs:4:1) + Valid substitutions include + a :: Int (defined at Defer03.hs:4:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Err’)) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at Defer03.hs:1:8-11 + (and originally defined in ‘GHC.Enum’)) diff --git a/testsuite/tests/module/mod71.stderr b/testsuite/tests/module/mod71.stderr index 7c95534256..4d592cea84 100644 --- a/testsuite/tests/module/mod71.stderr +++ b/testsuite/tests/module/mod71.stderr @@ -10,3 +10,9 @@ mod71.hs:4:9: error: • Relevant bindings include x :: t1 -> t -> t2 (bound at mod71.hs:4:3) f :: (t1 -> t -> t2) -> t2 (bound at mod71.hs:4:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at mod71.hs:3:8 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/partial-sigs/should_compile/T12531.stderr b/testsuite/tests/partial-sigs/should_compile/T12531.stderr index ddd68246a1..df83c1a2ed 100644 --- a/testsuite/tests/partial-sigs/should_compile/T12531.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T12531.stderr @@ -7,3 +7,9 @@ T12531.hs:6:11: warning: [-Wtyped-holes (in -Wdefault)] • Relevant bindings include x :: Int# (bound at T12531.hs:6:3) f :: Int# -> Int (bound at T12531.hs:6:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T12531.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/th/T10267.stderr b/testsuite/tests/th/T10267.stderr index e255178839..0ac32fad1c 100644 --- a/testsuite/tests/th/T10267.stderr +++ b/testsuite/tests/th/T10267.stderr @@ -10,6 +10,12 @@ T10267.hs:8:1: error: • Relevant bindings include x :: a (bound at T10267.hs:8:1) j :: a -> a (bound at T10267.hs:8:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) T10267.hs:8:1: error: • Found hole: _foo :: a -> a @@ -21,6 +27,18 @@ T10267.hs:8:1: error: • In the expression: _foo In an equation for ‘i’: i = _foo • Relevant bindings include i :: a -> a (bound at T10267.hs:8:1) + Valid substitutions include + l :: forall a. a -> a (defined at T10267.hs:23:3) + k :: forall a. a -> a (defined at T10267.hs:14:3) + foo :: forall a. a -> a (defined at T10267.hs:33:1) + id :: forall a. a -> a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) T10267.hs:14:3: error: • Found hole: _foo :: a -> a @@ -32,6 +50,17 @@ T10267.hs:14:3: error: • In the expression: _foo In an equation for ‘k’: k = _foo • Relevant bindings include k :: a -> a (bound at T10267.hs:14:3) + Valid substitutions include + l :: forall a. a -> a (defined at T10267.hs:23:3) + foo :: forall a. a -> a (defined at T10267.hs:33:1) + id :: forall a. a -> a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) T10267.hs:23:3: error: • Found hole: _ :: a @@ -44,3 +73,9 @@ T10267.hs:23:3: error: • Relevant bindings include x :: a (bound at T10267.hs:23:3) l :: a -> a (bound at T10267.hs:23:3) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T10267.hs:3:8-13 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/T13050.stderr b/testsuite/tests/typecheck/should_compile/T13050.stderr index 723bdf02b6..4f9410ed80 100644 --- a/testsuite/tests/typecheck/should_compile/T13050.stderr +++ b/testsuite/tests/typecheck/should_compile/T13050.stderr @@ -8,6 +8,60 @@ T13050.hs:4:9: warning: [-Wtyped-holes (in -Wdefault)] y :: Int (bound at T13050.hs:4:5) x :: Int (bound at T13050.hs:4:3) f :: Int -> Int -> Int (bound at T13050.hs:4:1) + Valid substitutions include + (-) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + asTypeOf :: forall a. a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + const :: forall a b. a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + (*) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (+) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + subtract :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (^) :: forall a b. (Num a, Integral b) => a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + div :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + gcd :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + lcm :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + mod :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + quot :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + rem :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Err’)) + max :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + min :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + seq :: forall a b. a -> b -> b + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Prim’)) T13050.hs:5:11: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: Int -> Int -> Int @@ -20,6 +74,59 @@ T13050.hs:5:11: warning: [-Wtyped-holes (in -Wdefault)] g :: Int -> Int -> Int (bound at T13050.hs:5:1) Valid substitutions include f :: Int -> Int -> Int (defined at T13050.hs:4:1) + (-) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + asTypeOf :: forall a. a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + const :: forall a b. a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + (*) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (+) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + subtract :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (^) :: forall a b. (Num a, Integral b) => a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + div :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + gcd :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + lcm :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + mod :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + quot :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + rem :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Err’)) + max :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + min :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + seq :: forall a b. a -> b -> b + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Prim’)) T13050.hs:6:11: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _a :: Int -> Int -> Int @@ -34,3 +141,56 @@ T13050.hs:6:11: warning: [-Wtyped-holes (in -Wdefault)] Valid substitutions include f :: Int -> Int -> Int (defined at T13050.hs:4:1) g :: Int -> Int -> Int (defined at T13050.hs:5:1) + (-) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + asTypeOf :: forall a. a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + const :: forall a b. a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Base’)) + (*) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (+) :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + subtract :: forall a. Num a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Num’)) + (^) :: forall a b. (Num a, Integral b) => a -> b -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + div :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + gcd :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + lcm :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + mod :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + quot :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + rem :: forall a. Integral a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Real’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Err’)) + max :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + min :: forall a. Ord a => a -> a -> a + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Classes’)) + seq :: forall a b. a -> b -> b + (imported from ‘Prelude’ at T13050.hs:1:8-17 + (and originally defined in ‘GHC.Prim’)) diff --git a/testsuite/tests/typecheck/should_compile/T9497a.stderr b/testsuite/tests/typecheck/should_compile/T9497a.stderr index ddbb5b93f6..413aad24b6 100644 --- a/testsuite/tests/typecheck/should_compile/T9497a.stderr +++ b/testsuite/tests/typecheck/should_compile/T9497a.stderr @@ -5,3 +5,15 @@ T9497a.hs:2:8: warning: [-Wtyped-holes (in -Wdefault)] • In the expression: _main In an equation for ‘main’: main = _main • Relevant bindings include main :: IO () (bound at T9497a.hs:2:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at T9497a.hs:1:1 + (and originally defined in ‘GHC.Base’)) + readLn :: forall a. Read a => IO a + (imported from ‘Prelude’ at T9497a.hs:1:1 + (and originally defined in ‘System.IO’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T9497a.hs:1:1 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index bcd6a4349f..ddf2376fe3 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -383,13 +383,13 @@ test('T7050', normal, compile, ['-O']) test('T7312', normal, compile, ['']) test('T7384', normal, compile, ['']) test('T7451', normal, compile, ['']) -test('holes', normal, compile, ['-fdefer-type-errors']) -test('holes2', normal, compile, ['-fdefer-type-errors']) -test('holes3', normal, compile_fail, ['']) -test('hole_constraints', normal, compile, ['-fdefer-type-errors']) -test('hole_constraints_nested', normal, compile, ['-fdefer-type-errors']) +test('holes', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions']) +test('holes2', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions']) +test('holes3', normal, compile_fail, ['-fno-max-valid-substitutions']) +test('hole_constraints', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions']) +test('hole_constraints_nested', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions']) test('valid_substitutions', [extra_files(['ValidSubs.hs'])], - multimod_compile, ['valid_substitutions','-fdefer-type-errors']) + multimod_compile, ['valid_substitutions','-fdefer-type-errors -fno-max-valid-substitutions']) test('T7408', normal, compile, ['']) test('UnboxStrictPrimitiveFields', normal, compile, ['']) test('T7541', normal, compile, ['']) @@ -535,7 +535,7 @@ test('T12911', normal, compile, ['']) test('T12925', normal, compile, ['']) test('T12919', expect_broken(12919), compile, ['']) test('T12936', normal, compile, ['']) -test('T13050', normal, compile, ['-fdefer-type-errors']) +test('T13050', normal, compile, ['-fdefer-type-errors -fno-max-valid-substitutions']) test('T13083', normal, compile, ['']) test('T11723', normal, compile, ['']) test('T12987', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_compile/hole_constraints.stderr b/testsuite/tests/typecheck/should_compile/hole_constraints.stderr index b464547365..98d76ce805 100644 --- a/testsuite/tests/typecheck/should_compile/hole_constraints.stderr +++ b/testsuite/tests/typecheck/should_compile/hole_constraints.stderr @@ -10,6 +10,12 @@ hole_constraints.hs:8:6: warning: [-Wtyped-holes (in -Wdefault)] • Relevant bindings include f1 :: a (bound at hole_constraints.hs:8:1) Constraints include Eq a (from hole_constraints.hs:7:1-15) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Err’)) hole_constraints.hs:12:6: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: a @@ -24,6 +30,13 @@ hole_constraints.hs:12:6: warning: [-Wtyped-holes (in -Wdefault)] Constraints include Show a (from hole_constraints.hs:11:1-25) Eq a (from hole_constraints.hs:11:1-25) + Valid substitutions include + f1 :: forall a. Eq a => a (defined at hole_constraints.hs:8:1) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Err’)) hole_constraints.hs:16:35: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: [a] @@ -35,6 +48,15 @@ hole_constraints.hs:16:35: warning: [-Wtyped-holes (in -Wdefault)] • Relevant bindings include f3 :: [a] (bound at hole_constraints.hs:16:30) Constraints include Eq a (from hole_constraints.hs:16:10-22) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Err’)) hole_constraints.hs:20:19: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: a @@ -48,6 +70,12 @@ hole_constraints.hs:20:19: warning: [-Wtyped-holes (in -Wdefault)] x :: a (bound at hole_constraints.hs:20:15) castWith :: (a :~: b) -> a -> b (bound at hole_constraints.hs:20:1) Constraints include b ~ a (from hole_constraints.hs:20:10-13) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Err’)) hole_constraints.hs:27:32: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: String @@ -59,3 +87,16 @@ hole_constraints.hs:27:32: warning: [-Wtyped-holes (in -Wdefault)] a :: AnyShow (bound at hole_constraints.hs:27:5) foo :: AnyShow -> String (bound at hole_constraints.hs:27:1) Constraints include Show a (from hole_constraints.hs:27:19-27) + Valid substitutions include + f1 :: forall a. Eq a => a (defined at hole_constraints.hs:8:1) + f2 :: forall a. (Show a, Eq a) => a + (defined at hole_constraints.hs:12:1) + f3 :: forall a. C a => a (defined at hole_constraints.hs:15:17) + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints.hs:3:8-22 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/hole_constraints_nested.stderr b/testsuite/tests/typecheck/should_compile/hole_constraints_nested.stderr index b41aec8946..a3fbbc6066 100644 --- a/testsuite/tests/typecheck/should_compile/hole_constraints_nested.stderr +++ b/testsuite/tests/typecheck/should_compile/hole_constraints_nested.stderr @@ -13,3 +13,15 @@ hole_constraints_nested.hs:12:16: warning: [-Wtyped-holes (in -Wdefault)] Eq a (from hole_constraints_nested.hs:12:7-11) Ord a (from hole_constraints_nested.hs:12:7-11) b ~ a (from hole_constraints_nested.hs:11:5-8) + Valid substitutions include + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at hole_constraints_nested.hs:3:8-28 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at hole_constraints_nested.hs:3:8-28 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at hole_constraints_nested.hs:3:8-28 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/holes.stderr b/testsuite/tests/typecheck/should_compile/holes.stderr index aadc844290..16d8ab794f 100644 --- a/testsuite/tests/typecheck/should_compile/holes.stderr +++ b/testsuite/tests/typecheck/should_compile/holes.stderr @@ -6,6 +6,12 @@ holes.hs:3:5: warning: [-Wtyped-holes (in -Wdefault)] • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: t (bound at holes.hs:3:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Err’)) holes.hs:6:7: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: Char @@ -14,6 +20,19 @@ holes.hs:6:7: warning: [-Wtyped-holes (in -Wdefault)] • Relevant bindings include x :: Int (bound at holes.hs:6:3) g :: Int -> Char (bound at holes.hs:6:1) + Valid substitutions include + f :: forall t. t (defined at holes.hs:3:1) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Err’)) holes.hs:8:5: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: [Char] @@ -21,6 +40,16 @@ holes.hs:8:5: warning: [-Wtyped-holes (in -Wdefault)] In the expression: _ ++ "a" In an equation for ‘h’: h = _ ++ "a" • Relevant bindings include h :: [Char] (bound at holes.hs:8:1) + Valid substitutions include + f :: forall t. t (defined at holes.hs:3:1) + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Err’)) holes.hs:11:15: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: b0 @@ -31,3 +60,14 @@ holes.hs:11:15: warning: [-Wtyped-holes (in -Wdefault)] • Relevant bindings include y :: [a] (bound at holes.hs:11:3) z :: [a] -> [a] (bound at holes.hs:11:1) + Valid substitutions include + f :: forall t. t (defined at holes.hs:3:1) + g :: Int -> Char (defined at holes.hs:6:1) + toEnum :: forall a. Enum a => Int -> a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes.hs:1:8-12 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/holes2.stderr b/testsuite/tests/typecheck/should_compile/holes2.stderr index 3744ef74f8..d7484fa142 100644 --- a/testsuite/tests/typecheck/should_compile/holes2.stderr +++ b/testsuite/tests/typecheck/should_compile/holes2.stderr @@ -4,11 +4,12 @@ holes2.hs:3:5: warning: [-Wdeferred-type-errors (in -Wdefault)] prevents the constraint ‘(Show a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: + instance (Show b, Show a) => Show (Either a b) + -- Defined in ‘Data.Either’ instance Show Ordering -- Defined in ‘GHC.Show’ instance Show Integer -- Defined in ‘GHC.Show’ - instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ - ...plus 22 others - ...plus six instances involving out-of-scope types + ...plus 23 others + ...plus 61 instances involving out-of-scope types (use -fprint-potential-instances to see them all) • In the expression: show _ In an equation for ‘f’: f = show _ @@ -20,3 +21,12 @@ holes2.hs:3:10: warning: [-Wtyped-holes (in -Wdefault)] In the expression: show _ In an equation for ‘f’: f = show _ • Relevant bindings include f :: String (bound at holes2.hs:3:1) + Valid substitutions include + pi :: forall a. Floating a => a + (imported from ‘Prelude’ at holes2.hs:1:8-13 + (and originally defined in ‘GHC.Float’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes2.hs:1:8-13 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/holes3.stderr b/testsuite/tests/typecheck/should_compile/holes3.stderr index 3a3fd572e1..76b6bbffe0 100644 --- a/testsuite/tests/typecheck/should_compile/holes3.stderr +++ b/testsuite/tests/typecheck/should_compile/holes3.stderr @@ -6,6 +6,12 @@ holes3.hs:3:5: error: • In the expression: _ In an equation for ‘f’: f = _ • Relevant bindings include f :: t (bound at holes3.hs:3:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Err’)) holes3.hs:6:7: error: • Found hole: _gr :: Char @@ -15,6 +21,19 @@ holes3.hs:6:7: error: • Relevant bindings include x :: Int (bound at holes3.hs:6:3) g :: Int -> Char (bound at holes3.hs:6:1) + Valid substitutions include + f :: forall t. t (defined at holes3.hs:3:1) + maxBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Enum’)) + minBound :: forall a. Bounded a => a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Err’)) holes3.hs:8:5: error: • Found hole: _aa :: [Char] @@ -23,6 +42,16 @@ holes3.hs:8:5: error: In the expression: _aa ++ "a" In an equation for ‘h’: h = _aa ++ "a" • Relevant bindings include h :: [Char] (bound at holes3.hs:8:1) + Valid substitutions include + f :: forall t. t (defined at holes3.hs:3:1) + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Err’)) holes3.hs:11:15: error: • Found hole: _x :: b0 @@ -34,3 +63,14 @@ holes3.hs:11:15: error: • Relevant bindings include y :: [a] (bound at holes3.hs:11:3) z :: [a] -> [a] (bound at holes3.hs:11:1) + Valid substitutions include + f :: forall t. t (defined at holes3.hs:3:1) + g :: Int -> Char (defined at holes3.hs:6:1) + toEnum :: forall a. Enum a => Int -> a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Enum’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at holes3.hs:1:8-13 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_compile/valid_substitutions.stderr b/testsuite/tests/typecheck/should_compile/valid_substitutions.stderr index a89c5f03a8..a0de0e2f13 100644 --- a/testsuite/tests/typecheck/should_compile/valid_substitutions.stderr +++ b/testsuite/tests/typecheck/should_compile/valid_substitutions.stderr @@ -11,6 +11,17 @@ valid_substitutions.hs:13:8: warning: [-Wtyped-holes (in -Wdefault)] In an equation for ‘test’: test = _ • Relevant bindings include test :: [Maybe a] -> [a] (bound at valid_substitutions.hs:13:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Base’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Err’)) + catMaybes :: forall a. [Maybe a] -> [a] + (imported from ‘Data.Maybe’ at valid_substitutions.hs:5:1-17) valid_substitutions.hs:16:9: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: Integer -> ValidSubs.Moo @@ -20,7 +31,11 @@ valid_substitutions.hs:16:9: warning: [-Wtyped-holes (in -Wdefault)] test2 :: Integer -> ValidSubs.Moo (bound at valid_substitutions.hs:16:1) Valid substitutions include - ValidSubs.Moo :: Integer -> ValidSubs.Moo + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Err’)) valid_substitutions.hs:19:8: warning: [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: [Char] -> IO () @@ -33,5 +48,28 @@ valid_substitutions.hs:19:8: warning: [-Wtyped-holes (in -Wdefault)] ps :: String -> IO () (defined at valid_substitutions.hs:9:1) System.IO.putStr :: String -> IO () (imported qualified from ‘System.IO’ at valid_substitutions.hs:4:1-26) + fail :: forall (m :: * -> *). Monad m => forall a. String -> m a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Base’)) + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Base’)) + print :: forall a. Show a => a -> IO () + (imported qualified from ‘System.IO’ at valid_substitutions.hs:4:1-26) putStrLn :: String -> IO () (imported qualified from ‘System.IO’ at valid_substitutions.hs:4:1-26) + readIO :: forall a. Read a => String -> IO a + (imported qualified from ‘System.IO’ at valid_substitutions.hs:4:1-26) + error :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + [Char] -> a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Err’)) + errorWithoutStackTrace :: forall (a :: TYPE r). [Char] -> a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Err’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at valid_substitutions.hs:3:1-30 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_fail/T12177.stderr b/testsuite/tests/typecheck/should_fail/T12177.stderr index ae57decfbc..45a55cf5b8 100644 --- a/testsuite/tests/typecheck/should_fail/T12177.stderr +++ b/testsuite/tests/typecheck/should_fail/T12177.stderr @@ -9,6 +9,12 @@ T12177.hs:3:19: error: • Relevant bindings include x :: p1 (bound at T12177.hs:3:14) bar :: p -> p1 -> t (bound at T12177.hs:3:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T12177.hs:1:8-10 + (and originally defined in ‘GHC.Err’)) T12177.hs:5:37: error: • Found hole: _ :: t @@ -23,3 +29,9 @@ T12177.hs:5:37: error: x :: p3 (bound at T12177.hs:5:26) y :: p1 (bound at T12177.hs:5:14) baz :: p -> p1 -> p2 -> p3 -> p4 -> t (bound at T12177.hs:5:1) + Valid substitutions include + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T12177.hs:1:8-10 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_fail/T9497d.stderr b/testsuite/tests/typecheck/should_fail/T9497d.stderr index 46121be1c1..a7b7bfb89a 100644 --- a/testsuite/tests/typecheck/should_fail/T9497d.stderr +++ b/testsuite/tests/typecheck/should_fail/T9497d.stderr @@ -5,3 +5,15 @@ T9497d.hs:2:8: error: • In the expression: _main In an equation for ‘main’: main = _main • Relevant bindings include main :: IO () (bound at T9497d.hs:2:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at T9497d.hs:1:1 + (and originally defined in ‘GHC.Base’)) + readLn :: forall a. Read a => IO a + (imported from ‘Prelude’ at T9497d.hs:1:1 + (and originally defined in ‘System.IO’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T9497d.hs:1:1 + (and originally defined in ‘GHC.Err’)) diff --git a/testsuite/tests/typecheck/should_run/T9497a-run.stderr b/testsuite/tests/typecheck/should_run/T9497a-run.stderr index 9a7ac000ec..ad3a9279ff 100644 --- a/testsuite/tests/typecheck/should_run/T9497a-run.stderr +++ b/testsuite/tests/typecheck/should_run/T9497a-run.stderr @@ -1,8 +1,20 @@ T9497a-run: T9497a-run.hs:2:8: error: - Found hole: _main :: IO () - Or perhaps ‘_main’ is mis-spelled, or not in scope - In the expression: _main - In an equation for ‘main’: main = _main - Relevant bindings include - main :: IO () (bound at T9497a-run.hs:2:1) + • Found hole: _main :: IO () + Or perhaps ‘_main’ is mis-spelled, or not in scope + • In the expression: _main + In an equation for ‘main’: main = _main + • Relevant bindings include + main :: IO () (bound at T9497a-run.hs:2:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at T9497a-run.hs:1:1 + (and originally defined in ‘GHC.Base’)) + readLn :: forall a. Read a => IO a + (imported from ‘Prelude’ at T9497a-run.hs:1:1 + (and originally defined in ‘System.IO’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T9497a-run.hs:1:1 + (and originally defined in ‘GHC.Err’)) (deferred type error) diff --git a/testsuite/tests/typecheck/should_run/T9497b-run.stderr b/testsuite/tests/typecheck/should_run/T9497b-run.stderr index 432b5fed2c..8836ee262e 100644 --- a/testsuite/tests/typecheck/should_run/T9497b-run.stderr +++ b/testsuite/tests/typecheck/should_run/T9497b-run.stderr @@ -1,8 +1,20 @@ T9497b-run: T9497b-run.hs:2:8: error: - Found hole: _main :: IO () - Or perhaps ‘_main’ is mis-spelled, or not in scope - In the expression: _main - In an equation for ‘main’: main = _main - Relevant bindings include - main :: IO () (bound at T9497b-run.hs:2:1) + • Found hole: _main :: IO () + Or perhaps ‘_main’ is mis-spelled, or not in scope + • In the expression: _main + In an equation for ‘main’: main = _main + • Relevant bindings include + main :: IO () (bound at T9497b-run.hs:2:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at T9497b-run.hs:1:1 + (and originally defined in ‘GHC.Base’)) + readLn :: forall a. Read a => IO a + (imported from ‘Prelude’ at T9497b-run.hs:1:1 + (and originally defined in ‘System.IO’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T9497b-run.hs:1:1 + (and originally defined in ‘GHC.Err’)) (deferred type error) diff --git a/testsuite/tests/typecheck/should_run/T9497c-run.stderr b/testsuite/tests/typecheck/should_run/T9497c-run.stderr index 61d8575d2c..829abf59e9 100644 --- a/testsuite/tests/typecheck/should_run/T9497c-run.stderr +++ b/testsuite/tests/typecheck/should_run/T9497c-run.stderr @@ -1,8 +1,20 @@ T9497c-run: T9497c-run.hs:2:8: error: - Found hole: _main :: IO () - Or perhaps ‘_main’ is mis-spelled, or not in scope - In the expression: _main - In an equation for ‘main’: main = _main - Relevant bindings include - main :: IO () (bound at T9497c-run.hs:2:1) + • Found hole: _main :: IO () + Or perhaps ‘_main’ is mis-spelled, or not in scope + • In the expression: _main + In an equation for ‘main’: main = _main + • Relevant bindings include + main :: IO () (bound at T9497c-run.hs:2:1) + Valid substitutions include + mempty :: forall a. Monoid a => a + (imported from ‘Prelude’ at T9497c-run.hs:1:1 + (and originally defined in ‘GHC.Base’)) + readLn :: forall a. Read a => IO a + (imported from ‘Prelude’ at T9497c-run.hs:1:1 + (and originally defined in ‘System.IO’)) + undefined :: forall (a :: TYPE r). + GHC.Stack.Types.HasCallStack => + a + (imported from ‘Prelude’ at T9497c-run.hs:1:1 + (and originally defined in ‘GHC.Err’)) (deferred type error) |