Commit 9612e91c authored by Richard Eisenberg's avatar Richard Eisenberg Committed by Marge Bot

Solve constraints from top-level groups sooner

Previously, all constraints from all top-level groups (as
separated by top-level splices) were lumped together and solved
at the end. This could leak metavariables to TH, though, and
that's bad. This patch solves each group's constraints before
running the next group's splice.

Naturally, we now report fewer errors in some cases.

One nice benefit is that this also fixes #11680, but in a much
simpler way than the original fix for that ticket. Admittedly,
the error messages degrade just a bit from the fix from #11680
(previously, we informed users about variables that will be
brought into scope below a top-level splice, and now we just
report an out-of-scope error), but the amount of complexity
required throughout GHC to get that error was just not worth it.

This patch thus reverts much of
f93c9517.

Fixes #16980

Test cases: th/T16980{,a}
parent bf02c264
Pipeline #11112 failed with stages
in 212 minutes and 44 seconds
......@@ -35,7 +35,6 @@ import CoreSyn
import DynFlags ( gopt, GeneralFlag(Opt_PrintExplicitCoercions) )
import Name
import NameSet
import RdrName ( GlobalRdrEnv )
import BasicTypes
import ConLike
import SrcLoc
......@@ -186,104 +185,6 @@ is Less Cool because
typecheck do-notation with (>>=) :: m1 a -> (a -> m2 b) -> m2 b.)
-}
-- | An unbound variable; used for treating
-- out-of-scope variables as expression holes
--
-- Either "x", "y" Plain OutOfScope
-- or "_", "_x" A TrueExprHole
--
-- Both forms indicate an out-of-scope variable, but the latter
-- indicates that the user /expects/ it to be out of scope, and
-- just wants GHC to report its type
data UnboundVar
= OutOfScope OccName GlobalRdrEnv -- ^ An (unqualified) out-of-scope
-- variable, together with the GlobalRdrEnv
-- with respect to which it is unbound
-- See Note [OutOfScope and GlobalRdrEnv]
| TrueExprHole OccName -- ^ A "true" expression hole (_ or _x)
deriving Data
instance Outputable UnboundVar where
ppr (OutOfScope occ _) = text "OutOfScope" <> parens (ppr occ)
ppr (TrueExprHole occ) = text "ExprHole" <> parens (ppr occ)
unboundVarOcc :: UnboundVar -> OccName
unboundVarOcc (OutOfScope occ _) = occ
unboundVarOcc (TrueExprHole occ) = occ
{-
Note [OutOfScope and GlobalRdrEnv]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To understand why we bundle a GlobalRdrEnv with an out-of-scope variable,
consider the following module:
module A where
foo :: ()
foo = bar
bat :: [Double]
bat = [1.2, 3.4]
$(return [])
bar = ()
bad = False
When A is compiled, the renamer determines that `bar` is not in scope in the
declaration of `foo` (since `bar` is declared in the following inter-splice
group). Once it has finished typechecking the entire module, the typechecker
then generates the associated error message, which specifies both the type of
`bar` and a list of possible in-scope alternatives:
A.hs:6:7: error:
• Variable not in scope: bar :: ()
• ‘bar’ (line 13) is not in scope before the splice on line 11
Perhaps you meant ‘bat’ (line 9)
When it calls RnEnv.unknownNameSuggestions to identify these alternatives, the
typechecker must provide a GlobalRdrEnv. If it provided the current one, which
contains top-level declarations for the entire module, the error message would
incorrectly suggest the out-of-scope `bar` and `bad` as possible alternatives
for `bar` (see #11680). Instead, the typechecker must use the same
GlobalRdrEnv the renamer used when it determined that `bar` is out-of-scope.
To obtain this GlobalRdrEnv, can the typechecker simply use the out-of-scope
`bar`'s location to either reconstruct it (from the current GlobalRdrEnv) or to
look it up in some global store? Unfortunately, no. The problem is that
location information is not always sufficient for this task. This is most
apparent when dealing with the TH function addTopDecls, which adds its
declarations to the FOLLOWING inter-splice group. Consider these declarations:
ex9 = cat -- cat is NOT in scope here
$(do -------------------------------------------------------------
ds <- [d| f = cab -- cat and cap are both in scope here
cat = ()
|]
addTopDecls ds
[d| g = cab -- only cap is in scope here
cap = True
|])
ex10 = cat -- cat is NOT in scope here
$(return []) -----------------------------------------------------
ex11 = cat -- cat is in scope
Here, both occurrences of `cab` are out-of-scope, and so the typechecker needs
the GlobalRdrEnvs which were used when they were renamed. These GlobalRdrEnvs
are different (`cat` is present only in the GlobalRdrEnv for f's `cab'), but the
locations of the two `cab`s are the same (they are both created in the same
splice). Thus, we must include some additional information with each `cab` to
allow the typechecker to obtain the correct GlobalRdrEnv. Clearly, the simplest
information to use is the GlobalRdrEnv itself.
-}
-- | A Haskell expression.
data HsExpr p
= HsVar (XVar p)
......@@ -292,7 +193,7 @@ data HsExpr p
-- See Note [Located RdrNames]
| HsUnboundVar (XUnboundVar p)
UnboundVar -- ^ Unbound variable; also used for "holes"
OccName -- ^ Unbound variable; also used for "holes"
-- (_ or _x).
-- Turned from HsVar to HsUnboundVar by the
-- renamer, when it finds an out-of-scope
......@@ -945,7 +846,7 @@ ppr_lexpr e = ppr_expr (unLoc e)
ppr_expr :: forall p. (OutputableBndrId (GhcPass p))
=> HsExpr (GhcPass p) -> SDoc
ppr_expr (HsVar _ (L _ v)) = pprPrefixOcc v
ppr_expr (HsUnboundVar _ uv)= pprPrefixOcc (unboundVarOcc uv)
ppr_expr (HsUnboundVar _ uv)= pprPrefixOcc uv
ppr_expr (HsConLikeOut _ c) = pprPrefixOcc c
ppr_expr (HsIPVar _ v) = ppr v
ppr_expr (HsOverLabel _ _ l)= char '#' <> ppr l
......@@ -1129,12 +1030,12 @@ ppr_expr (HsRecFld _ f) = ppr f
ppr_expr (XExpr x) = ppr x
ppr_infix_expr :: (OutputableBndrId (GhcPass p)) => HsExpr (GhcPass p) -> Maybe SDoc
ppr_infix_expr (HsVar _ (L _ v)) = Just (pprInfixOcc v)
ppr_infix_expr (HsConLikeOut _ c)= Just (pprInfixOcc (conLikeName c))
ppr_infix_expr (HsRecFld _ f) = Just (pprInfixOcc f)
ppr_infix_expr (HsUnboundVar _ h@TrueExprHole{}) = Just (pprInfixOcc (unboundVarOcc h))
ppr_infix_expr (HsWrap _ _ e) = ppr_infix_expr e
ppr_infix_expr _ = Nothing
ppr_infix_expr (HsVar _ (L _ v)) = Just (pprInfixOcc v)
ppr_infix_expr (HsConLikeOut _ c) = Just (pprInfixOcc (conLikeName c))
ppr_infix_expr (HsRecFld _ f) = Just (pprInfixOcc f)
ppr_infix_expr (HsUnboundVar _ occ) = Just (pprInfixOcc occ)
ppr_infix_expr (HsWrap _ _ e) = ppr_infix_expr e
ppr_infix_expr _ = Nothing
ppr_apps :: (OutputableBndrId (GhcPass p))
=> HsExpr (GhcPass p)
......
......@@ -1394,7 +1394,7 @@ repE (ArithSeq _ _ aseq) =
repE (HsSpliceE _ splice) = repSplice splice
repE (HsStatic _ e) = repLE e >>= rep2 staticEName . (:[]) . unC
repE (HsUnboundVar _ uv) = do
occ <- occNameLit (unboundVarOcc uv)
occ <- occNameLit uv
sname <- repNameS occ
repUnboundVar sname
......
......@@ -2102,7 +2102,7 @@ patSynErr l e explanation =
; return (cL l hsHoleExpr) }
hsHoleExpr :: HsExpr (GhcPass id)
hsHoleExpr = HsUnboundVar noExtField (TrueExprHole (mkVarOcc "_"))
hsHoleExpr = HsUnboundVar noExtField (mkVarOcc "_")
-- | See Note [Ambiguous syntactic categories] and Note [PatBuilder]
data PatBuilder p
......
......@@ -108,11 +108,7 @@ rnUnboundVar v
then -- Treat this as a "hole"
-- Do not fail right now; instead, return HsUnboundVar
-- and let the type checker report the error
do { let occ = rdrNameOcc v
; uv <- if startsWithUnderscore occ
then return (TrueExprHole occ)
else OutOfScope occ <$> getGlobalRdrEnv
; return (HsUnboundVar noExtField uv, emptyFVs) }
return (HsUnboundVar noExtField (rdrNameOcc v), emptyFVs)
else -- Fail immediately (qualified name)
do { n <- reportUnboundName v
......
......@@ -1141,7 +1141,7 @@ badRuleLhsErr name lhs bad_e
text "LHS must be of form (f e1 .. en) where f is not forall'd"
where
err = case bad_e of
HsUnboundVar _ uv -> notInScopeErr (mkRdrUnqual (unboundVarOcc uv))
HsUnboundVar _ uv -> notInScopeErr (mkRdrUnqual uv)
_ -> text "Illegal expression:" <+> ppr bad_e
{- **************************************************************
......
......@@ -1180,7 +1180,7 @@ mkOpAppRn e1 op fix e2 -- Default case, no rearrangment
-- | Name of an operator in an operator application or section
data OpName = NormalOp Name -- ^ A normal identifier
| NegateOp -- ^ Prefix negation
| UnboundOp UnboundVar -- ^ An unbound indentifier
| UnboundOp OccName -- ^ An unbound indentifier
| RecFldOp (AmbiguousFieldOcc GhcRn)
-- ^ A (possibly ambiguous) record field occurrence
......@@ -1347,7 +1347,7 @@ checkSectionPrec direction section op arg
lookupFixityOp :: OpName -> RnM Fixity
lookupFixityOp (NormalOp n) = lookupFixityRn n
lookupFixityOp NegateOp = lookupFixityRn negateName
lookupFixityOp (UnboundOp u) = lookupFixityRn (mkUnboundName (unboundVarOcc u))
lookupFixityOp (UnboundOp u) = lookupFixityRn (mkUnboundName u)
lookupFixityOp (RecFldOp f) = lookupFieldFixityRn f
......
......@@ -521,7 +521,6 @@ mergeSignatures
-- tcg_dus?
-- tcg_th_used = tcg_th_used orig_tcg_env,
-- tcg_th_splice_used = tcg_th_splice_used orig_tcg_env
-- tcg_th_top_level_locs = tcg_th_top_level_locs orig_tcg_env
}) $ do
tcg_env <- getGblEnv
......
......@@ -32,6 +32,7 @@ import FamInst ( tcTopNormaliseNewTypeTF_maybe )
import Var
import VarEnv( mkInScopeSet )
import VarSet( delVarSetList )
import OccName ( OccName )
import Outputable
import DynFlags( DynFlags )
import NameSet
......@@ -134,8 +135,8 @@ canonicalize (CFunEqCan { cc_ev = ev
= {-# SCC "canEqLeafFunEq" #-}
canCFunEqCan ev fn xis1 fsk
canonicalize (CHoleCan { cc_ev = ev, cc_hole = hole })
= canHole ev hole
canonicalize (CHoleCan { cc_ev = ev, cc_occ = occ, cc_hole = hole })
= canHole ev occ hole
{-
************************************************************************
......@@ -640,13 +641,14 @@ canIrred ev
_ -> continueWith $
mkIrredCt new_ev } }
canHole :: CtEvidence -> Hole -> TcS (StopOrContinue Ct)
canHole ev hole
canHole :: CtEvidence -> OccName -> HoleSort -> TcS (StopOrContinue Ct)
canHole ev occ hole_sort
= do { let pred = ctEvPred ev
; (xi,co) <- flatten FM_SubstOnly ev pred -- co :: xi ~ pred
; rewriteEvidence ev xi co `andWhenContinue` \ new_ev ->
do { updInertIrreds (`snocCts` (CHoleCan { cc_ev = new_ev
, cc_hole = hole }))
, cc_occ = occ
, cc_hole = hole_sort }))
; stopWith new_ev "Emit insoluble hole" } }
......
This diff is collapsed.
......@@ -1848,7 +1848,7 @@ tc_infer_id lbl id_name
| otherwise = return ()
tcUnboundId :: HsExpr GhcRn -> UnboundVar -> ExpRhoType -> TcM (HsExpr GhcTcId)
tcUnboundId :: HsExpr GhcRn -> OccName -> ExpRhoType -> TcM (HsExpr GhcTcId)
-- Typecheck an occurrence of an unbound Id
--
-- Some of these started life as a true expression hole "_".
......@@ -1857,12 +1857,11 @@ tcUnboundId :: HsExpr GhcRn -> UnboundVar -> ExpRhoType -> TcM (HsExpr GhcTcId)
-- We turn all of them into HsVar, since HsUnboundVar can't contain an
-- Id; and indeed the evidence for the CHoleCan does bind it, so it's
-- not unbound any more!
tcUnboundId rn_expr unbound res_ty
tcUnboundId rn_expr occ res_ty
= do { ty <- newOpenFlexiTyVarTy -- Allow Int# etc (#12531)
; let occ = unboundVarOcc unbound
; name <- newSysName occ
; let ev = mkLocalId name ty
; can <- newHoleCt (ExprHole unbound) ev ty
; can <- newHoleCt ExprHole ev ty
; emitInsoluble can
; tcWrapResultO (UnboundOccurrenceOf occ) rn_expr
(HsVar noExtField (noLoc ev)) ty res_ty }
......
......@@ -960,7 +960,8 @@ zonkExpr env (HsWrap x co_fn expr)
new_expr <- zonkExpr env1 expr
return (HsWrap x new_co_fn new_expr)
zonkExpr _ e@(HsUnboundVar {}) = return e
zonkExpr _ e@(HsUnboundVar {})
= return e
zonkExpr _ expr = pprPanic "zonkExpr" (ppr expr)
......
......@@ -183,13 +183,14 @@ newWanteds :: CtOrigin -> ThetaType -> TcM [CtEvidence]
newWanteds orig = mapM (newWanted orig Nothing)
-- | Create a new 'CHoleCan' 'Ct'.
newHoleCt :: Hole -> Id -> Type -> TcM Ct
newHoleCt :: HoleSort -> Id -> Type -> TcM Ct
newHoleCt hole ev ty = do
loc <- getCtLocM HoleOrigin Nothing
pure $ CHoleCan { cc_ev = CtWanted { ctev_pred = ty
, ctev_dest = EvVarDest ev
, ctev_nosh = WDeriv
, ctev_loc = loc }
, cc_occ = getOccName ev
, cc_hole = hole }
----------------------------------------------
......
......@@ -586,8 +586,11 @@ tc_rn_src_decls ds
{ Nothing -> return (tcg_env, tcl_env, lie1)
-- If there's a splice, we must carry on
; Just (SpliceDecl _ (dL->L loc splice) _, rest_ds) ->
do { recordTopLevelSpliceLoc loc
; Just (SpliceDecl _ (dL->L _ splice) _, rest_ds) ->
do {
-- We need to simplify any constraints from the previous declaration
-- group, or else we might reify metavariables, as in #16980.
; ev_binds1 <- simplifyTop lie1
-- Rename the splice expression, and get its supporting decls
; (spliced_decls, splice_fvs) <- rnTopSpliceDecls splice
......@@ -595,9 +598,10 @@ tc_rn_src_decls ds
-- Glue them on the front of the remaining decls and loop
; (tcg_env, tcl_env, lie2) <-
setGblEnv (tcg_env `addTcgDUs` usesOnly splice_fvs) $
addTopEvBinds ev_binds1 $
tc_rn_src_decls (spliced_decls ++ rest_ds)
; return (tcg_env, tcl_env, lie1 `andWC` lie2)
; return (tcg_env, tcl_env, lie2)
}
; Just (XSpliceDecl nec, _) -> noExtCon nec
}
......
......@@ -107,8 +107,8 @@ module TcRnMonad(
emitNamedWildCardHoleConstraints, emitAnonWildCardHoleConstraint,
-- * Template Haskell context
recordThUse, recordThSpliceUse, recordTopLevelSpliceLoc,
getTopLevelSpliceLocs, keepAlive, getStage, getStageAndBindLevel, setStage,
recordThUse, recordThSpliceUse,
keepAlive, getStage, getStageAndBindLevel, setStage,
addModFinalizersWithLclEnv,
-- * Safe Haskell context
......@@ -183,8 +183,6 @@ import qualified GHC.LanguageExtensions as LangExt
import Data.IORef
import Control.Monad
import Data.Set ( Set )
import qualified Data.Set as Set
import {-# SOURCE #-} TcEnv ( tcInitTidyEnv )
......@@ -214,7 +212,6 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this
used_gre_var <- newIORef [] ;
th_var <- newIORef False ;
th_splice_var<- newIORef False ;
th_locs_var <- newIORef Set.empty ;
infer_var <- newIORef (True, emptyBag) ;
dfun_n_var <- newIORef emptyOccSet ;
type_env_var <- case hsc_type_env_var hsc_env of {
......@@ -274,8 +271,6 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this
tcg_ann_env = emptyAnnEnv,
tcg_th_used = th_var,
tcg_th_splice_used = th_splice_var,
tcg_th_top_level_locs
= th_locs_var,
tcg_exports = [],
tcg_imports = emptyImportAvails,
tcg_used_gres = used_gre_var,
......@@ -1681,7 +1676,8 @@ emitAnonWildCardHoleConstraint tv
; emitInsolubles $ unitBag $
CHoleCan { cc_ev = CtDerived { ctev_pred = mkTyVarTy tv
, ctev_loc = ct_loc }
, cc_hole = TypeHole (mkTyVarOcc "_") } }
, cc_occ = mkTyVarOcc "_"
, cc_hole = TypeHole } }
emitNamedWildCardHoleConstraints :: [(Name, TcTyVar)] -> TcM ()
emitNamedWildCardHoleConstraints wcs
......@@ -1693,7 +1689,8 @@ emitNamedWildCardHoleConstraints wcs
do_one ct_loc (name, tv)
= CHoleCan { cc_ev = CtDerived { ctev_pred = mkTyVarTy tv
, ctev_loc = ct_loc' }
, cc_hole = TypeHole (occName name) }
, cc_occ = occName name
, cc_hole = TypeHole }
where
real_span = case nameSrcSpan name of
RealSrcSpan span -> span
......@@ -1768,22 +1765,6 @@ recordThUse = do { env <- getGblEnv; writeTcRef (tcg_th_used env) True }
recordThSpliceUse :: TcM ()
recordThSpliceUse = do { env <- getGblEnv; writeTcRef (tcg_th_splice_used env) True }
-- | When generating an out-of-scope error message for a variable matching a
-- binding in a later inter-splice group, the typechecker uses the splice
-- locations to provide details in the message about the scope of that binding.
recordTopLevelSpliceLoc :: SrcSpan -> TcM ()
recordTopLevelSpliceLoc (RealSrcSpan real_loc)
= do { env <- getGblEnv
; let locs_var = tcg_th_top_level_locs env
; locs0 <- readTcRef locs_var
; writeTcRef locs_var (Set.insert real_loc locs0) }
recordTopLevelSpliceLoc (UnhelpfulSpan _) = return ()
getTopLevelSpliceLocs :: TcM (Set RealSrcSpan)
getTopLevelSpliceLocs
= do { env <- getGblEnv
; readTcRef (tcg_th_top_level_locs env) }
keepAlive :: Name -> TcRn () -- Record the name in the keep-alive set
keepAlive name
= do { env <- getGblEnv
......
......@@ -136,7 +136,7 @@ module TcRnTypes(
-- Misc other types
TcId, TcIdSet,
Hole(..), holeOcc,
HoleSort(..),
NameShape(..),
-- Role annotations
......@@ -197,7 +197,7 @@ import CostCentreState
import Control.Monad (ap, msum)
import qualified Control.Monad.Fail as MonadFail
import Data.Set ( Set )
import Data.Set ( Set )
import qualified Data.Set as S
import Data.List ( sort )
......@@ -573,10 +573,6 @@ data TcGblEnv
--
-- Splices disable recompilation avoidance (see #481)
tcg_th_top_level_locs :: TcRef (Set RealSrcSpan),
-- ^ Locations of the top-level splices; used for providing details on
-- scope in error messages for out-of-scope variables
tcg_dfun_n :: TcRef OccSet,
-- ^ Allows us to choose unique DFun names.
......@@ -1785,7 +1781,8 @@ data Ct
-- Treated as an "insoluble" constraint
-- See Note [Insoluble constraints]
cc_ev :: CtEvidence,
cc_hole :: Hole
cc_occ :: OccName, -- The name of this hole
cc_hole :: HoleSort -- The sort of this hole (expr, type, ...)
}
| CQuantCan QCInst -- A quantified constraint
......@@ -1808,27 +1805,19 @@ instance Outputable QCInst where
ppr (QCI { qci_ev = ev }) = ppr ev
------------
-- | An expression or type hole
data Hole = ExprHole UnboundVar
-- ^ Either an out-of-scope variable or a "true" hole in an
-- expression (TypedHoles)
| TypeHole OccName
-- ^ A hole in a type (PartialTypeSignatures)
instance Outputable Hole where
ppr (ExprHole ub) = ppr ub
ppr (TypeHole occ) = text "TypeHole" <> parens (ppr occ)
holeOcc :: Hole -> OccName
holeOcc (ExprHole uv) = unboundVarOcc uv
holeOcc (TypeHole occ) = occ
-- | Used to indicate which sort of hole we have.
data HoleSort = ExprHole
-- ^ Either an out-of-scope variable or a "true" hole in an
-- expression (TypedHoles)
| TypeHole
-- ^ A hole in a type (PartialTypeSignatures)
{- Note [Hole constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~
CHoleCan constraints are used for two kinds of holes,
distinguished by cc_hole:
* For holes in expressions (including variables not in scope)
* For holes in expressions
e.g. f x = g _ x
* For holes in type signatures
......@@ -1945,7 +1934,7 @@ instance Outputable Ct where
CIrredCan { cc_insol = insol }
| insol -> text "CIrredCan(insol)"
| otherwise -> text "CIrredCan(sol)"
CHoleCan { cc_hole = hole } -> text "CHoleCan:" <+> ppr hole
CHoleCan { cc_occ = occ } -> text "CHoleCan:" <+> ppr occ
CQuantCan (QCI { qci_pend_sc = pend_sc })
| pend_sc -> text "CQuantCan(psc)"
| otherwise -> text "CQuantCan"
......@@ -2227,17 +2216,18 @@ isHoleCt (CHoleCan {}) = True
isHoleCt _ = False
isOutOfScopeCt :: Ct -> Bool
-- We treat expression holes representing out-of-scope variables a bit
-- differently when it comes to error reporting
isOutOfScopeCt (CHoleCan { cc_hole = ExprHole (OutOfScope {}) }) = True
-- A Hole that does not have a leading underscore is
-- simply an out-of-scope variable, and we treat that
-- a bit differently when it comes to error reporting
isOutOfScopeCt (CHoleCan { cc_occ = occ }) = not (startsWithUnderscore occ)
isOutOfScopeCt _ = False
isExprHoleCt :: Ct -> Bool
isExprHoleCt (CHoleCan { cc_hole = ExprHole {} }) = True
isExprHoleCt (CHoleCan { cc_hole = ExprHole }) = True
isExprHoleCt _ = False
isTypeHoleCt :: Ct -> Bool
isTypeHoleCt (CHoleCan { cc_hole = TypeHole {} }) = True
isTypeHoleCt (CHoleCan { cc_hole = TypeHole }) = True
isTypeHoleCt _ = False
......@@ -3709,7 +3699,7 @@ lexprCtOrigin (L _ e) = exprCtOrigin e
exprCtOrigin :: HsExpr GhcRn -> CtOrigin
exprCtOrigin (HsVar _ (L _ name)) = OccurrenceOf name
exprCtOrigin (HsUnboundVar _ uv) = UnboundOccurrenceOf (unboundVarOcc uv)
exprCtOrigin (HsUnboundVar _ uv) = UnboundOccurrenceOf uv
exprCtOrigin (HsConLikeOut {}) = panic "exprCtOrigin HsConLikeOut"
exprCtOrigin (HsRecFld _ f) = OccurrenceOfRecSel (rdrNameAmbiguousFieldOcc f)
exprCtOrigin (HsOverLabel _ _ l) = OverLabelOrigin l
......
......@@ -31,7 +31,6 @@ import GhcPrelude
import Bag
import Class ( Class, classKey, classTyCon )
import DynFlags
import GHC.Hs.Expr ( UnboundVar(..) )
import Id ( idType, mkLocalId )
import Inst
import ListSetOps
......@@ -39,7 +38,6 @@ import Name
import Outputable
import PrelInfo
import PrelNames
import RdrName ( emptyGlobalRdrEnv )
import TcErrors
import TcEvidence
import TcInteract
......@@ -657,8 +655,7 @@ tcNormalise given_ids ty
let occ = mkVarOcc "$tcNorm"
name <- newSysName occ
let ev = mkLocalId name ty
hole = ExprHole $ OutOfScope occ emptyGlobalRdrEnv
newHoleCt hole ev ty
newHoleCt ExprHole ev ty
{- Note [Superclasses and satisfiability]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -34,8 +34,8 @@ fromModule (GreHFCand gre) =
fromModule _ = []
toHoleFitCommand :: TypedHole -> String -> Maybe String
toHoleFitCommand TyH{tyHCt = Just (CHoleCan _ h)} str
= stripPrefix ("_" <> str) $ occNameString $ holeOcc h
toHoleFitCommand TyH{tyHCt = Just (CHoleCan _ h _)} str
= stripPrefix ("_" <> str) $ occNameString h
toHoleFitCommand _ _ = Nothing
......
......@@ -27,58 +27,7 @@ T10267.hs:8:1: error:
j :: forall a0. a0 -> a0
with j @a
(bound at T10267.hs:8:1)
k :: forall a. a -> a
with k @a
(defined at T10267.hs:14:3)
l :: forall a. a -> a
with l @a
(defined at T10267.hs:23:3)
foo :: forall a. a -> a
with foo @a
(defined at T10267.hs:33:1)
id :: forall a. a -> a
with id @a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Base’))
T10267.hs:14:3: error:
• Found hole: _foo :: a -> a
Where: ‘a’ is a rigid type variable bound by
the type signature for:
k :: forall a. a -> a
at T10267.hs:(14,3)-(21,2)
Or perhaps ‘_foo’ is mis-spelled, or not in scope
• In the expression: _foo
In an equation for ‘k’: k = _foo
• Relevant bindings include k :: a -> a (bound at T10267.hs:14:3)
Valid hole fits include
k :: a -> a (bound at T10267.hs:14:3)
j :: forall a0. a0 -> a0
with j @a
(bound at T10267.hs:8:1)
i :: forall a0. a0 -> a0
with i @a
(bound at T10267.hs:8:1)
l :: forall a. a -> a
with l @a
(defined at T10267.hs:23:3)
foo :: forall a. a -> a
with foo @a
(defined at T10267.hs:33:1)
id :: forall a. a -> a
with id @a
(imported from ‘Prelude’ at T10267.hs:3:8-13
(and originally defined in ‘GHC.Base’))
T10267.hs:23:3: error:
• Found hole: _ :: a
Where: ‘a’ is a rigid type variable bound by
the type signature for:
l :: forall a. a -> a
at T10267.hs:(23,3)-(30,2)
• In the expression: _
In an equation for ‘l’: l x = _
• Relevant bindings include
x :: a (bound at T10267.hs:23:3)
l :: a -> a (bound at T10267.hs:23:3)
Valid hole fits include x :: a (bound at T10267.hs:23:3)
......@@ -5,25 +5,17 @@ T11680.hs:20:7: error:
• Variable not in scope: abce :: [a]
• Perhaps you meant ‘abcd’ (line 23)
T11680.hs:31:7: error:
• Variable not in scope: foo :: Int
• ‘foo’ (line 100) is not in scope before the splice on line 96
T11680.hs:31:7: error: Variable not in scope: foo :: Int
T11680.hs:39:7: error:
• Variable not in scope: bar :: ()
• ‘bar’ (line 110) is not in scope
before the splice on lines 106-108
Perhaps you meant one of these: ‘bat’ (line 42), ‘baz’ (line 45)
• Perhaps you meant one of these: ‘bat’ (line 42), ‘baz’ (line 45)
T11680.hs:50:7: error:
• Variable not in scope: ns :: [Double]
• ‘ns’ (splice on lines 106-108) is not in scope before line 106
T11680.hs:50:7: error: Variable not in scope: ns :: [Double]
T11680.hs:55:7: error:
• Variable not in scope: intercalate
• ‘intercalate’ (line 114) is not in scope
before the splice on lines 106-108
Perhaps you meant ‘List.intercalate’ (imported from Data.List)
• Perhaps you meant ‘List.intercalate’ (imported from Data.List)
T11680.hs:59:7: error:
• Variable not in scope: nub
......@@ -33,17 +25,4 @@ T11680.hs:64:7: error: Variable not in scope: x :: t0 -> Int
T11680.hs:69:7: error:
• Variable not in scope: cat :: ()
• ‘cat’ (splice on lines 79-86) is not in scope before line 79
Perhaps you meant ‘bat’ (line 42)
T11680.hs:79:3: error:
• Variable not in scope: cab
• Perhaps you meant ‘cap’ (line 79)
T11680.hs:79:3: error:
• Variable not in scope: cab
• Perhaps you meant one of these: ‘cat’ (line 79), ‘cap’ (line 79)
T11680.hs:91:8: error:
• Variable not in scope: cat :: ()
• Perhaps you meant one of these: ‘bat’ (line 42), ‘cap’ (line 79)
• Perhaps you meant ‘bat’ (line 42)
{-# LANGUAGE TemplateHaskell #-}
module T16980 where
import Language.Haskell.TH
import Language.Haskell.TH.Ppr
import System.IO
aNumber = 5
do VarI name1 t1 _ <- reify 'aNumber
runIO . print $ ppr_sig name1 t1
runIO . print =<< reifyType 'aNumber
runIO $ hFlush stdout
return []
T16980.aNumber :: GHC.Integer.Type.Integer
ConT GHC.Integer.Type.Integer
module T16980a where
default (Integer) -- just to be really explicit
x = 5 -- this should be an Integer
$(return [])
y :: Int
y = x -- this should be a type error; types cannot communicate across splices