Matthew Pickering pushed to branch wip/improve-implicit-lifting-error at Glasgow Haskell Compiler / GHC

Commits:

17 changed files:

Changes:

  • compiler/GHC/Hs/Expr.hs
    ... ... @@ -55,6 +55,7 @@ import GHC.Types.SourceText
    55 55
     import GHC.Types.SrcLoc
    
    56 56
     import GHC.Types.Tickish (CoreTickish)
    
    57 57
     import GHC.Types.Unique.Set (UniqSet)
    
    58
    +import GHC.Types.ThLevelIndex
    
    58 59
     import GHC.Core.ConLike ( conLikeName, ConLike )
    
    59 60
     import GHC.Unit.Module (ModuleName)
    
    60 61
     import GHC.Utils.Misc
    
    ... ... @@ -78,7 +79,7 @@ import Data.Foldable ( toList )
    78 79
     import Data.List.NonEmpty (NonEmpty (..))
    
    79 80
     import qualified Data.List.NonEmpty as NE
    
    80 81
     import Data.Void (Void)
    
    81
    -
    
    82
    +import qualified Data.Set as S
    
    82 83
     {- *********************************************************************
    
    83 84
     *                                                                      *
    
    84 85
                     Expressions proper
    
    ... ... @@ -2252,8 +2253,12 @@ data UntypedSpliceFlavour
    2252 2253
       deriving Data
    
    2253 2254
     
    
    2254 2255
     -- | Pending Renamer Splice
    
    2256
    +-- There are two types of pending splices:
    
    2257
    +-- 1. A splice explicitly written by the user, e.g. `[| $(foo) |]`
    
    2258
    +-- 2. A cross-stage reference which we will attempt to fix by using Lift.
    
    2255 2259
     data PendingRnSplice
    
    2256 2260
       = PendingRnSplice UntypedSpliceFlavour SplicePointName (LHsExpr GhcRn)
    
    2261
    +  | PendingImplicitLift (S.Set ThLevelIndex) ThLevelIndex (Maybe GlobalRdrElt) (LIdOccP GhcRn)
    
    2257 2262
     
    
    2258 2263
     -- | Pending Type-checker Splice
    
    2259 2264
     data PendingTcSplice
    
    ... ... @@ -2346,6 +2351,7 @@ thTyBrackets pp_body = text "[||" <+> pp_body <+> text "||]"
    2346 2351
     
    
    2347 2352
     instance Outputable PendingRnSplice where
    
    2348 2353
       ppr (PendingRnSplice _ n e) = pprPendingSplice n e
    
    2354
    +  ppr (PendingImplicitLift _bound _used _gre n) = text "implicit lift:" <+> ppr n
    
    2349 2355
     
    
    2350 2356
     instance Outputable PendingTcSplice where
    
    2351 2357
       ppr (PendingTcSplice n e) = pprPendingSplice n e
    

  • compiler/GHC/Iface/Ext/Ast.hs
    ... ... @@ -2027,6 +2027,7 @@ instance ToHie (HsQuote GhcRn) where
    2027 2027
     
    
    2028 2028
     instance ToHie PendingRnSplice where
    
    2029 2029
       toHie (PendingRnSplice _ _ e) = toHie e
    
    2030
    +  toHie (PendingImplicitLift _bound _used _gre l) = toHie @(LHsExpr GhcRn) (L (l2l (getLoc l)) (HsVar noExtField l))
    
    2030 2031
     
    
    2031 2032
     instance ToHie PendingTcSplice where
    
    2032 2033
       toHie (PendingTcSplice _ e) = toHie e
    

  • compiler/GHC/Rename/Expr.hs
    ... ... @@ -328,7 +328,7 @@ rnExpr (HsVar _ (L l v))
    328 328
                 -- matching GRE and add a name clash error
    
    329 329
                 -- (see lookupGlobalOccRn_overloaded, called by lookupExprOccRn).
    
    330 330
                 -> do { let sel_name = flSelector $ recFieldLabel fld_info
    
    331
    -                  ; unless (isExact v || isOrig v) $ checkThLocalNameWithLift sel_name
    
    331
    +                  ; unless (isExact v || isOrig v) $ checkThLocalNameWithLift (L (l2l l) (WithUserRdr v sel_name))
    
    332 332
                       ; return (XExpr (HsRecSelRn (FieldOcc v  (L l sel_name))), unitFV sel_name)
    
    333 333
                       }
    
    334 334
                 | nm == nilDataConName
    
    ... ... @@ -339,8 +339,9 @@ rnExpr (HsVar _ (L l v))
    339 339
                 -> rnExpr (ExplicitList noAnn [])
    
    340 340
     
    
    341 341
                 | otherwise
    
    342
    -            -> do { unless (isExact v || isOrig v) (checkThLocalNameWithLift nm)
    
    343
    -                  ; return (HsVar noExtField (L (l2l l) (WithUserRdr v nm)), unitFV nm) }
    
    342
    +            -> do { let res_name = L (l2l l) (WithUserRdr v nm)
    
    343
    +                  ; unless (isExact v || isOrig v) (checkThLocalNameWithLift res_name)
    
    344
    +                  ; return (HsVar noExtField res_name, unitFV nm) }
    
    344 345
             }}}
    
    345 346
     
    
    346 347
     
    

  • compiler/GHC/Rename/Splice.hs
    ... ... @@ -51,7 +51,7 @@ import GHC.Data.FastString
    51 51
     import GHC.Utils.Logger
    
    52 52
     import GHC.Utils.Panic
    
    53 53
     import GHC.Driver.Hooks
    
    54
    -import GHC.Builtin.Names.TH ( decsQTyConName, expQTyConName, liftName
    
    54
    +import GHC.Builtin.Names.TH ( decsQTyConName, expQTyConName
    
    55 55
                                 , patQTyConName, quoteDecName, quoteExpName
    
    56 56
                                 , quotePatName, quoteTypeName, typeQTyConName)
    
    57 57
     
    
    ... ... @@ -184,7 +184,8 @@ rnUntypedBracket e br_body
    184 184
     rn_utbracket :: HsQuote GhcPs -> RnM (HsQuote GhcRn, FreeVars)
    
    185 185
     rn_utbracket (VarBr _ flg rdr_name)
    
    186 186
       = do { name <- lookupOccRn (if flg then WL_Term else WL_Type) (unLoc rdr_name)
    
    187
    -       ; if flg then checkThLocalNameNoLift name else checkThLocalTyName name
    
    187
    +       ; let res_name = L (l2l (locA rdr_name)) (WithUserRdr (unLoc rdr_name) name)
    
    188
    +       ; if flg then checkThLocalNameNoLift res_name else checkThLocalTyName name
    
    188 189
            ; check_namespace flg name
    
    189 190
            ; return (VarBr noExtField flg (noLocA name), unitFV name) }
    
    190 191
     
    
    ... ... @@ -423,9 +424,10 @@ rnUntypedSplice (HsUntypedSpliceExpr annCo expr)
    423 424
     rnUntypedSplice (HsQuasiQuote ext quoter quote)
    
    424 425
       = do  { -- Rename the quoter; akin to the HsVar case of rnExpr
    
    425 426
             ; quoter' <- lookupOccRn WL_TermVariable quoter
    
    427
    +        ; let res_name = noLocA (WithUserRdr quoter quoter')
    
    426 428
             ; this_mod <- getModule
    
    427 429
             ; when (nameIsLocalOrFrom this_mod quoter') $
    
    428
    -          checkThLocalNameNoLift quoter'
    
    430
    +          checkThLocalNameNoLift res_name
    
    429 431
     
    
    430 432
             ; return (HsQuasiQuote ext quoter' quote, unitFV quoter') }
    
    431 433
     
    
    ... ... @@ -932,17 +934,17 @@ checkThLocalTyName name
    932 934
     -- | Check whether we are allowed to use a Name in this context (for TH purposes)
    
    933 935
     -- In the case of a level incorrect program, attempt to fix it by using
    
    934 936
     -- a Lift constraint.
    
    935
    -checkThLocalNameWithLift :: Name -> RnM ()
    
    937
    +checkThLocalNameWithLift :: LIdOccP GhcRn -> RnM ()
    
    936 938
     checkThLocalNameWithLift = checkThLocalName True
    
    937 939
     
    
    938 940
     -- | Check whether we are allowed to use a Name in this context (for TH purposes)
    
    939 941
     -- In the case of a level incorrect program, do not attempt to fix it by using
    
    940 942
     -- a Lift constraint.
    
    941
    -checkThLocalNameNoLift :: Name -> RnM ()
    
    943
    +checkThLocalNameNoLift :: LIdOccP GhcRn -> RnM ()
    
    942 944
     checkThLocalNameNoLift = checkThLocalName False
    
    943 945
     
    
    944
    -checkThLocalName :: Bool -> Name -> RnM ()
    
    945
    -checkThLocalName allow_lifting name
    
    946
    +checkThLocalName :: Bool -> LIdOccP GhcRn -> RnM ()
    
    947
    +checkThLocalName allow_lifting name_var
    
    946 948
       | isUnboundName name   -- Do not report two errors for
    
    947 949
       = return ()            --   $(not_in_scope args)
    
    948 950
     
    
    ... ... @@ -964,7 +966,9 @@ checkThLocalName allow_lifting name
    964 966
             ; dflags <- getDynFlags
    
    965 967
             ; env <- getGlobalRdrEnv
    
    966 968
             ; let mgre = lookupGRE_Name env name
    
    967
    -        ; checkCrossLevelLifting dflags (LevelCheckSplice name mgre) top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name } } }
    
    969
    +        ; checkCrossLevelLifting dflags (LevelCheckSplice name mgre) top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name_var } } }
    
    970
    +  where
    
    971
    +    name = getName name_var
    
    968 972
     
    
    969 973
     --------------------------------------
    
    970 974
     checkCrossLevelLifting :: DynFlags
    
    ... ... @@ -975,8 +979,8 @@ checkCrossLevelLifting :: DynFlags
    975 979
                            -> Set.Set ThLevelIndex
    
    976 980
                            -> ThLevel
    
    977 981
                            -> ThLevelIndex
    
    978
    -                       -> Name -> TcM ()
    
    979
    -checkCrossLevelLifting dflags reason top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name
    
    982
    +                       -> LIdOccP GhcRn -> TcM ()
    
    983
    +checkCrossLevelLifting dflags reason top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name_var
    
    980 984
       -- 1. If name is in-scope, at the correct level.
    
    981 985
       | use_lvl_idx `Set.member` bind_lvl = return ()
    
    982 986
       -- 2. Name is imported with -XImplicitStagePersistence
    
    ... ... @@ -993,52 +997,26 @@ checkCrossLevelLifting dflags reason top_lvl is_local allow_lifting bind_lvl use
    993 997
       , any (use_lvl_idx >=) (Set.toList bind_lvl)
    
    994 998
       , allow_lifting
    
    995 999
       = do
    
    996
    -      dflags <- getDynFlags
    
    997
    -      check_cross_level_lifting dflags top_lvl name ps_var
    
    1000
    +      let mgre = case reason of
    
    1001
    +                  LevelCheckSplice _ gre -> gre
    
    1002
    +                  _ -> Nothing
    
    1003
    +      let pend_splice = PendingImplicitLift bind_lvl use_lvl_idx mgre name_var
    
    1004
    +       -- Warning for implicit lift (#17804)
    
    1005
    +      addDetailedDiagnostic (TcRnImplicitLift name)
    
    1006
    +
    
    1007
    +       -- Update the pending splices
    
    1008
    +      ps <- readMutVar ps_var
    
    1009
    +      writeMutVar ps_var (pend_splice : ps)
    
    998 1010
       -- 5. For a typed bracket, these checks happen again later on (checkThLocalId)
    
    999 1011
       -- In the future we should do all the level checks here.
    
    1000 1012
       | Brack _ RnPendingTyped <- use_lvl  -- Lift for typed brackets is inserted later.
    
    1001 1013
       , any (use_lvl_idx >=) (Set.toList bind_lvl)
    
    1002 1014
         = return ()
    
    1003 1015
       -- Otherwise, we have a level error, report.
    
    1004
    -  | otherwise = addErrTc (TcRnBadlyLevelled reason bind_lvl use_lvl_idx)
    
    1005
    -
    
    1006
    -check_cross_level_lifting :: DynFlags -> TopLevelFlag -> Name -> TcRef [PendingRnSplice] -> TcM ()
    
    1007
    -check_cross_level_lifting dflags top_lvl name ps_var
    
    1008
    -  | isTopLevel top_lvl
    
    1009
    -  , xopt LangExt.ImplicitStagePersistence dflags
    
    1010
    -        -- Top-level identifiers in this module,
    
    1011
    -        -- (which have External Names)
    
    1012
    -        -- are just like the imported case:
    
    1013
    -        -- no need for the 'lifting' treatment
    
    1014
    -        -- E.g.  this is fine:
    
    1015
    -        --   f x = x
    
    1016
    -        --   g y = [| f 3 |]
    
    1017
    -  = when (isExternalName name) (keepAlive name)
    
    1018
    -    -- See Note [Keeping things alive for Template Haskell]
    
    1016
    +  | otherwise = addErrTc (TcRnBadlyLevelled reason bind_lvl use_lvl_idx Nothing ErrorWithoutFlag)
    
    1017
    +  where
    
    1018
    +    name = getName name_var
    
    1019 1019
     
    
    1020
    -  | otherwise
    
    1021
    -  =     -- Nested identifiers, such as 'x' in
    
    1022
    -        -- E.g. \x -> [| h x |]
    
    1023
    -        -- We must behave as if the reference to x was
    
    1024
    -        --      h $(lift x)
    
    1025
    -        -- We use 'x' itself as the SplicePointName, used by
    
    1026
    -        -- the desugarer to stitch it all back together.
    
    1027
    -        -- If 'x' occurs many times we may get many identical
    
    1028
    -        -- bindings of the same SplicePointName, but that doesn't
    
    1029
    -        -- matter, although it's a mite untidy.
    
    1030
    -    do  { traceRn "checkCrossLevelLifting" (ppr name)
    
    1031
    -
    
    1032
    -          -- Construct the (lift x) expression
    
    1033
    -        ; let lift_expr   = nlHsApp (nlHsVar liftName) (nlHsVar name)
    
    1034
    -              pend_splice = PendingRnSplice UntypedExpSplice name lift_expr
    
    1035
    -
    
    1036
    -          -- Warning for implicit lift (#17804)
    
    1037
    -        ; addDetailedDiagnostic (TcRnImplicitLift name)
    
    1038
    -
    
    1039
    -          -- Update the pending splices
    
    1040
    -        ; ps <- readMutVar ps_var
    
    1041
    -        ; writeMutVar ps_var (pend_splice : ps) }
    
    1042 1020
     
    
    1043 1021
     checkCrossLevelLiftingTy :: DynFlags -> TopLevelFlag -> Set.Set ThLevelIndex -> ThLevel -> ThLevelIndex -> Name -> TcM ()
    
    1044 1022
     checkCrossLevelLiftingTy dflags top_lvl bind_lvl _use_lvl use_lvl_idx name
    

  • compiler/GHC/Tc/Errors.hs
    ... ... @@ -610,6 +610,7 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    610 610
         report1 = [ ("custom_error", is_user_type_error, True,  mkUserTypeErrorReporter)
    
    611 611
                      -- (Handles TypeError and Unsatisfiable)
    
    612 612
     
    
    613
    +              , ("implicit lifting", is_implicit_lifting, True, mkImplicitLiftingReporter)
    
    613 614
                   , given_eq_spec
    
    614 615
                   , ("insoluble2",      utterly_wrong,  True, mkGroupReporter mkEqErr)
    
    615 616
                   , ("skolem eq1",      very_wrong,     True, mkSkolReporter)
    
    ... ... @@ -671,6 +672,11 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    671 672
         -- See also Note [Implementation of Unsatisfiable constraints], point (F).
    
    672 673
         is_user_type_error item _ = containsUserTypeError (errorItemPred item)
    
    673 674
     
    
    675
    +    is_implicit_lifting item _ =
    
    676
    +      case (errorItemOrigin item) of
    
    677
    +        ImplicitLiftOrigin {} -> True
    
    678
    +        _ -> False
    
    679
    +
    
    674 680
         is_homo_equality _ (EqPred _ ty1 ty2)
    
    675 681
           = typeKind ty1 `tcEqType` typeKind ty2
    
    676 682
         is_homo_equality _ _
    
    ... ... @@ -1082,7 +1088,7 @@ mkUserTypeErrorReporter :: Reporter
    1082 1088
     mkUserTypeErrorReporter ctxt
    
    1083 1089
       = mapM_ $ \item -> do { let err = important ctxt $ mkUserTypeError item
    
    1084 1090
                             ; maybeReportError ctxt (item :| []) err
    
    1085
    -                        ; addDeferredBinding err item }
    
    1091
    +                        ; addSolverDeferredBinding err item }
    
    1086 1092
     
    
    1087 1093
     mkUserTypeError :: ErrorItem -> TcSolverReportMsg
    
    1088 1094
     mkUserTypeError item
    
    ... ... @@ -1095,6 +1101,21 @@ mkUserTypeError item
    1095 1101
       where
    
    1096 1102
         pty = errorItemPred item
    
    1097 1103
     
    
    1104
    +mkImplicitLiftingReporter :: Reporter
    
    1105
    +mkImplicitLiftingReporter ctxt
    
    1106
    +  = mapM_ $ \item -> do { let err = mkImplicitLiftingError item
    
    1107
    +                        ; msg <- mkErrorReport (ctLocEnv (errorItemCtLoc item)) err (Just ctxt) [] []
    
    1108
    +                        ; reportDiagnostic msg
    
    1109
    +                        ; addDeferredBinding ctxt [] [] err item
    
    1110
    +                        }
    
    1111
    +
    
    1112
    +  where
    
    1113
    +    mkImplicitLiftingError :: ErrorItem -> TcRnMessage
    
    1114
    +    mkImplicitLiftingError item =
    
    1115
    +      case errorItemOrigin item of
    
    1116
    +        ImplicitLiftOrigin bound used gre name -> TcRnBadlyLevelled (LevelCheckSplice name gre) bound used (Just item) (cec_defer_type_errors ctxt)
    
    1117
    +        _ -> pprPanic "mkImplicitLiftingError" (ppr item)
    
    1118
    +
    
    1098 1119
     mkGivenErrorReporter :: Reporter
    
    1099 1120
     -- See Note [Given errors]
    
    1100 1121
     mkGivenErrorReporter ctxt (item:|_)
    
    ... ... @@ -1192,7 +1213,7 @@ reportGroup mk_err ctxt items
    1192 1213
            ; maybeReportError ctxt items err
    
    1193 1214
                -- But see Note [Always warn with -fdefer-type-errors]
    
    1194 1215
            ; traceTc "reportGroup" (ppr items)
    
    1195
    -       ; mapM_ (addDeferredBinding err) items }
    
    1216
    +       ; mapM_ (addSolverDeferredBinding err) items }
    
    1196 1217
                -- Add deferred bindings for all
    
    1197 1218
                -- Redundant if we are going to abort compilation,
    
    1198 1219
                -- but that's hard to know for sure, and if we don't
    
    ... ... @@ -1225,15 +1246,23 @@ maybeReportError ctxt items@(item1:|_) (SolverReport { sr_important_msg = import
    1225 1246
            msg <- mkErrorReport (ctLocEnv (errorItemCtLoc item1)) diag (Just ctxt) supp hints
    
    1226 1247
            reportDiagnostic msg
    
    1227 1248
     
    
    1228
    -addDeferredBinding :: SolverReport -> ErrorItem -> TcM ()
    
    1249
    +addSolverDeferredBinding :: SolverReport -> ErrorItem -> TcM ()
    
    1250
    +addSolverDeferredBinding err item =
    
    1251
    +  let ctxt = reportContext . sr_important_msg $ err
    
    1252
    +      supp = sr_supplementary err
    
    1253
    +      hints = sr_hints err
    
    1254
    +      important = sr_important_msg err
    
    1255
    +  in addDeferredBinding ctxt supp hints (TcRnSolverReport important ErrorWithoutFlag) item
    
    1256
    +
    
    1257
    +
    
    1258
    +addDeferredBinding :: SolverReportErrCtxt -> [SupplementaryInfo] -> [GhcHint] -> TcRnMessage -> ErrorItem -> TcM ()
    
    1229 1259
     -- See Note [Deferring coercion errors to runtime]
    
    1230
    -addDeferredBinding err (EI { ei_evdest = Just dest
    
    1231
    -                           , ei_pred = item_ty
    
    1232
    -                           , ei_loc = loc })
    
    1260
    +addDeferredBinding ctxt supp hints msg (EI { ei_evdest = Just dest
    
    1261
    +                                           , ei_pred = item_ty
    
    1262
    +                                           , ei_loc = loc })
    
    1233 1263
       -- if evdest is Just, then the constraint was from a wanted
    
    1234
    -  | let ctxt = reportContext . sr_important_msg $ err
    
    1235
    -  , deferringAnyBindings ctxt
    
    1236
    -  = do { err_tm <- mkErrorTerm loc item_ty err
    
    1264
    +  | deferringAnyBindings ctxt
    
    1265
    +  = do { err_tm <- mkErrorTerm loc item_ty ctxt msg supp hints
    
    1237 1266
            ; let ev_binds_var = cec_binds ctxt
    
    1238 1267
     
    
    1239 1268
            ; case dest of
    
    ... ... @@ -1244,15 +1273,24 @@ addDeferredBinding err (EI { ei_evdest = Just dest
    1244 1273
                          let co_var = coHoleCoVar hole
    
    1245 1274
                        ; addTcEvBind ev_binds_var $ mkWantedEvBind co_var EvNonCanonical err_tm
    
    1246 1275
                        ; fillCoercionHole hole (mkCoVarCo co_var) } }
    
    1247
    -addDeferredBinding _ _ = return ()    -- Do not set any evidence for Given
    
    1276
    +addDeferredBinding _ _ _ _ _ = return ()    -- Do not set any evidence for Given
    
    1277
    +
    
    1278
    +mkSolverErrorTerm :: CtLoc -> Type  -- of the error term
    
    1279
    +                  -> SolverReport -> TcM EvTerm
    
    1280
    +mkSolverErrorTerm ct_loc ty err
    
    1281
    +  = mkErrorTerm ct_loc ty (reportContext . sr_important_msg $ err)
    
    1282
    +                          (TcRnSolverReport (sr_important_msg err) ErrorWithoutFlag)
    
    1283
    +                          (sr_supplementary err)
    
    1284
    +                          (sr_hints err)
    
    1248 1285
     
    
    1249 1286
     mkErrorTerm :: CtLoc -> Type  -- of the error term
    
    1250
    -            -> SolverReport -> TcM EvTerm
    
    1251
    -mkErrorTerm ct_loc ty (SolverReport { sr_important_msg = important, sr_supplementary = supp, sr_hints = hints })
    
    1287
    +            -> SolverReportErrCtxt -> TcRnMessage
    
    1288
    +            -> [SupplementaryInfo] -> [GhcHint] -> TcM EvTerm
    
    1289
    +mkErrorTerm ct_loc ty ctxt msg supp hints
    
    1252 1290
       = do { msg <- mkErrorReport
    
    1253 1291
                       (ctLocEnv ct_loc)
    
    1254
    -                  (TcRnSolverReport important ErrorWithoutFlag)
    
    1255
    -                  (Just $ reportContext important)
    
    1292
    +                  msg
    
    1293
    +                  (Just $ ctxt)
    
    1256 1294
                       supp
    
    1257 1295
                       hints
    
    1258 1296
              -- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
    
    ... ... @@ -1526,7 +1564,7 @@ maybeAddDeferredBindings hole report = do
    1526 1564
           -- not for holes in partial type signatures
    
    1527 1565
           -- cf. addDeferredBinding
    
    1528 1566
           when (deferringAnyBindings ctxt) $ do
    
    1529
    -        err_tm <- mkErrorTerm (hole_loc hole) ref_ty report
    
    1567
    +        err_tm <- mkSolverErrorTerm (hole_loc hole) ref_ty report
    
    1530 1568
               -- NB: ref_ty, not hole_ty. hole_ty might be rewritten.
    
    1531 1569
               -- See Note [Holes in expressions] in GHC.Hs.Expr
    
    1532 1570
             writeMutVar ref err_tm
    

  • compiler/GHC/Tc/Errors/Ppr.hs
    ... ... @@ -105,6 +105,7 @@ import GHC.Types.Var
    105 105
     import GHC.Types.Var.Set
    
    106 106
     import GHC.Types.Var.Env
    
    107 107
     import GHC.Types.Fixity (defaultFixity)
    
    108
    +import GHC.Types.ThLevelIndex (pprThBindLevel)
    
    108 109
     
    
    109 110
     import GHC.Iface.Errors.Types
    
    110 111
     import GHC.Iface.Errors.Ppr
    
    ... ... @@ -1517,23 +1518,8 @@ instance Diagnostic TcRnMessage where
    1517 1518
           hsep [ text "Unknown type variable" <> plural errorVars
    
    1518 1519
                , text "on the RHS of injectivity condition:"
    
    1519 1520
                , interpp'SP errorVars ]
    
    1520
    -    TcRnBadlyLevelled reason bind_lvls use_lvl
    
    1521
    -      ->
    
    1522
    -      mkSimpleDecorated $
    
    1523
    -         vcat $
    
    1524
    -         [ fsep [ text "Level error:", pprLevelCheckReason reason
    
    1525
    -                , text "is bound at" <+> pprThBindLevel bind_lvls
    
    1526
    -                , text "but used at level" <+> ppr use_lvl]
    
    1527
    -         ] ++
    
    1528
    -         [ fsep [ text "Hint: quoting" <+> thBrackets (ppUnless (isValName n) "t") (ppr n)
    
    1529
    -                , text "or an enclosing expression"
    
    1530
    -                , text "would allow the quotation to be used at an earlier level"
    
    1531
    -                ]
    
    1532
    -         | LevelCheckSplice n _ <- [reason]
    
    1533
    -         ] ++
    
    1534
    -         [ "From imports" <+> (ppr (gre_imp gre))
    
    1535
    -         | LevelCheckSplice _ (Just gre) <- [reason]
    
    1536
    -         , not (isEmptyBag (gre_imp gre)) ]
    
    1521
    +    TcRnBadlyLevelled reason bind_lvls use_lvl lift_attempt _reason
    
    1522
    +      -> pprTcRnBadlyLevelled reason bind_lvls use_lvl lift_attempt
    
    1537 1523
         TcRnBadlyLevelledType name bind_lvls use_lvl
    
    1538 1524
           -> mkSimpleDecorated $
    
    1539 1525
              text "Badly levelled type:" <+> ppr name <+>
    
    ... ... @@ -2490,8 +2476,8 @@ instance Diagnostic TcRnMessage where
    2490 2476
           -> ErrorWithoutFlag
    
    2491 2477
         TcRnUnknownTyVarsOnRhsOfInjCond{}
    
    2492 2478
           -> ErrorWithoutFlag
    
    2493
    -    TcRnBadlyLevelled{}
    
    2494
    -      -> ErrorWithoutFlag
    
    2479
    +    TcRnBadlyLevelled _ _ _ _ reason
    
    2480
    +      -> reason
    
    2495 2481
         TcRnBadlyLevelledType{}
    
    2496 2482
           -> WarningWithFlag Opt_WarnBadlyLevelledTypes
    
    2497 2483
         TcRnTyThingUsedWrong{}
    
    ... ... @@ -3389,6 +3375,22 @@ instance Diagnostic TcRnMessage where
    3389 3375
     
    
    3390 3376
       diagnosticCode = constructorCode @GHC
    
    3391 3377
     
    
    3378
    +pprTcRnBadlyLevelled :: LevelCheckReason -> Set.Set ThLevelIndex -> ThLevelIndex -> Maybe ErrorItem -> DecoratedSDoc
    
    3379
    +pprTcRnBadlyLevelled reason bind_lvls use_lvl lift_attempt = mkDecorated $
    
    3380
    +         [ fsep [ text "Level error:", pprLevelCheckReason reason
    
    3381
    +                , text "is bound at" <+> pprThBindLevel bind_lvls
    
    3382
    +                , text "but used at level" <+> ppr use_lvl]
    
    3383
    +         ] ++
    
    3384
    +         [hang (text "Could not be resolved by implicit lifting due to the following error:") 2
    
    3385
    +          (text "No instance for:" <+> quotes (ppr (errorItemPred item)))
    
    3386
    +         | Just item <- [lift_attempt]
    
    3387
    +         ] ++
    
    3388
    +         [ vcat (text "Available from the imports:" : ppr_imports (gre_imp gre))
    
    3389
    +         | LevelCheckSplice _ (Just gre) <- [reason]
    
    3390
    +         , not (isEmptyBag (gre_imp gre)) ]
    
    3391
    +  where
    
    3392
    +    ppr_imports :: Bag ImportSpec -> [SDoc]
    
    3393
    +    ppr_imports = map ((bullet <+>) . ppr ) . bagToList
    
    3392 3394
     
    
    3393 3395
     note :: SDoc -> SDoc
    
    3394 3396
     note note = "Note" <> colon <+> note <> dot
    
    ... ... @@ -4537,8 +4539,7 @@ pprMismatchMsg ctxt (CouldNotDeduce useful_givens (item :| others) mb_extra)
    4537 4539
                   : pp_givens useful_givens)
    
    4538 4540
     
    
    4539 4541
         supplementary = case mb_extra of
    
    4540
    -      Nothing
    
    4541
    -        -> Left []
    
    4542
    +      Nothing -> Right empty
    
    4542 4543
           Just (CND_Extra level ty1 ty2)
    
    4543 4544
             -> mk_supplementary_ea_msg ctxt level ty1 ty2 orig
    
    4544 4545
         ct_loc = errorItemCtLoc item
    
    ... ... @@ -7491,6 +7492,3 @@ pprErrCtxtMsg = \case
    7491 7492
           text "in" <+> quotes (ppr req_uid) <> dot
    
    7492 7493
     
    
    7493 7494
     --------------------------------------------------------------------------------
    7494
    -
    
    7495
    -pprThBindLevel :: Set.Set ThLevelIndex -> SDoc
    
    7496
    -pprThBindLevel levels_set = text "level" <> pluralSet levels_set <+> pprUnquotedSet levels_set
    \ No newline at end of file

  • compiler/GHC/Tc/Errors/Types.hs
    ... ... @@ -3497,6 +3497,8 @@ data TcRnMessage where
    3497 3497
         :: !LevelCheckReason -- ^ The binding
    
    3498 3498
         -> !(Set.Set ThLevelIndex) -- ^ The binding levels
    
    3499 3499
         -> !ThLevelIndex -- ^ The level at which the binding is used.
    
    3500
    +    -> !(Maybe ErrorItem) -- ^ The attempt we made to implicitly lift the binding.
    
    3501
    +    -> DiagnosticReason   -- ^ Whether to defer this error or fail
    
    3500 3502
         -> TcRnMessage
    
    3501 3503
     
    
    3502 3504
       {-| TcRnBadlyLevelledWarn is a warning that occurs when a TH type binding is
    

  • compiler/GHC/Tc/Gen/Splice.hs
    ... ... @@ -54,6 +54,7 @@ import GHC.Tc.Errors.Types
    54 54
     import GHC.Tc.Utils.Monad
    
    55 55
     import GHC.Tc.Utils.TcType
    
    56 56
     import GHC.Tc.Gen.Expr
    
    57
    +import GHC.Tc.Gen.Head
    
    57 58
     import GHC.Tc.Utils.Unify
    
    58 59
     import GHC.Tc.Utils.Env
    
    59 60
     import GHC.Tc.Types.Origin
    
    ... ... @@ -720,8 +721,8 @@ tcUntypedBracket rn_expr brack ps res_ty
    720 721
            -- Match the expected type with the type of all the internal
    
    721 722
            -- splices. They might have further constrained types and if they do
    
    722 723
            -- we want to reflect that in the overall type of the bracket.
    
    723
    -       ; ps' <- case quoteWrapperTyVarTy <$> brack_info of
    
    724
    -                  Just m_var -> mapM (tcPendingSplice m_var) ps
    
    724
    +       ; ps' <- case brack_info of
    
    725
    +                  Just q -> mapM (tcPendingSplice q) ps
    
    725 726
                       Nothing -> assert (null ps) $ return []
    
    726 727
     
    
    727 728
            -- Notice that we don't attempt to typecheck the body
    
    ... ... @@ -781,11 +782,11 @@ brackTy b =
    781 782
     
    
    782 783
     ---------------
    
    783 784
     -- | Typechecking a pending splice from a untyped bracket
    
    784
    -tcPendingSplice :: TcType -- Metavariable for the expected overall type of the
    
    785
    +tcPendingSplice :: QuoteWrapper -- Metavariable for the expected overall type of the
    
    785 786
                               -- quotation.
    
    786 787
                     -> PendingRnSplice
    
    787 788
                     -> TcM PendingTcSplice
    
    788
    -tcPendingSplice m_var (PendingRnSplice flavour splice_name expr)
    
    789
    +tcPendingSplice (QuoteWrapper _ m_var) (PendingRnSplice flavour splice_name expr)
    
    789 790
       -- See Note [Typechecking Overloaded Quotes]
    
    790 791
       = do { meta_ty <- tcMetaTy meta_ty_name
    
    791 792
              -- Expected type of splice, e.g. m Exp
    
    ... ... @@ -799,6 +800,26 @@ tcPendingSplice m_var (PendingRnSplice flavour splice_name expr)
    799 800
                            UntypedPatSplice  -> patTyConName
    
    800 801
                            UntypedTypeSplice -> typeTyConName
    
    801 802
                            UntypedDeclSplice -> decsTyConName
    
    803
    +  -- Identifiers that are lifted implicitly, such as 'x' in
    
    804
    +  -- E.g. \x -> [| h x |]
    
    805
    +  -- We must behave as if the reference to x was
    
    806
    +  --      h $(lift x)
    
    807
    +  -- We use 'x' itself as the SplicePointName, used by
    
    808
    +  -- the desugarer to stitch it all back together.
    
    809
    +  -- If 'x' occurs many times we may get many identical
    
    810
    +  -- bindings of the same SplicePointName, but that doesn't
    
    811
    +  -- matter, although it's a mite untidy.
    
    812
    +tcPendingSplice q (PendingImplicitLift bound used gre id_name)
    
    813
    +  = do { (id_expr, id_ty) <- tcInferId id_name
    
    814
    +         -- lift :: Quote m' => a -> m' Exp
    
    815
    +         ; lift <- setSrcSpan (getLocA id_name) $
    
    816
    +                    newMethodFromName (ImplicitLiftOrigin bound used gre (getName id_name))
    
    817
    +                                       GHC.Builtin.Names.TH.liftName
    
    818
    +                                       [getRuntimeRep id_ty, id_ty]
    
    819
    +         ; let res = nlHsApp (mkLHsWrap (applyQuoteWrapper q) (noLocA lift)) (noLocA id_expr)
    
    820
    +
    
    821
    +         ; return (PendingTcSplice (getName id_name) res) }
    
    822
    +
    
    802 823
     
    
    803 824
     ---------------
    
    804 825
     -- Takes a m and tau and returns the type m (TExp tau)
    

  • compiler/GHC/Tc/Solver/Monad.hs
    ... ... @@ -1652,7 +1652,7 @@ checkCrossLevelClsInst dflags reason bind_lvls use_lvl_idx is_local
    1652 1652
       -- With ImplicitStagePersistence, using later than bound is fine
    
    1653 1653
       | xopt LangExt.ImplicitStagePersistence dflags
    
    1654 1654
       , any (use_lvl_idx >=) bind_lvls  = return ()
    
    1655
    -  | otherwise = TcM.addErrTc (TcRnBadlyLevelled reason bind_lvls use_lvl_idx)
    
    1655
    +  | otherwise = TcM.addErrTc (TcRnBadlyLevelled reason bind_lvls use_lvl_idx Nothing ErrorWithoutFlag)
    
    1656 1656
     
    
    1657 1657
     
    
    1658 1658
     
    

  • compiler/GHC/Tc/Types/Origin.hs
    ... ... @@ -80,11 +80,13 @@ import GHC.Utils.Monad
    80 80
     import GHC.Utils.Misc( HasDebugCallStack )
    
    81 81
     import GHC.Types.Unique
    
    82 82
     import GHC.Types.Unique.Supply
    
    83
    +import GHC.Types.ThLevelIndex
    
    83 84
     
    
    84 85
     import Language.Haskell.Syntax.Basic (FieldLabelString(..))
    
    85 86
     
    
    86 87
     import qualified Data.Kind as Hs
    
    87 88
     import Data.List.NonEmpty (NonEmpty (..))
    
    89
    +import qualified Data.Set as S
    
    88 90
     
    
    89 91
     {- *********************************************************************
    
    90 92
     *                                                                      *
    
    ... ... @@ -647,6 +649,7 @@ data CtOrigin
    647 649
           Type   -- the instance-sig type
    
    648 650
           Type   -- the instantiated type of the method
    
    649 651
       | AmbiguityCheckOrigin UserTypeCtxt
    
    652
    +  | ImplicitLiftOrigin (S.Set ThLevelIndex) ThLevelIndex (Maybe GlobalRdrElt) Name
    
    650 653
     
    
    651 654
     data NonLinearPatternReason
    
    652 655
       = LazyPatternReason
    
    ... ... @@ -944,6 +947,7 @@ pprCtO (UsageEnvironmentOf x) = hsep [text "multiplicity of", quotes (ppr x)]
    944 947
     pprCtO (OmittedFieldOrigin Nothing) = text "an omitted anonymous field"
    
    945 948
     pprCtO (OmittedFieldOrigin (Just fl)) = hsep [text "omitted field" <+> quotes (ppr fl)]
    
    946 949
     pprCtO BracketOrigin         = text "a quotation bracket"
    
    950
    +pprCtO (ImplicitLiftOrigin _ _ _ n) = text "an implicit lift of" <+> quotes (ppr n)
    
    947 951
     
    
    948 952
     -- These ones are handled by pprCtOrigin, but we nevertheless sometimes
    
    949 953
     -- get here via callStackOriginFS, when doing ambiguity checks
    
    ... ... @@ -978,7 +982,6 @@ pprNonLinearPatternReason PatternSynonymReason = parens (text "pattern synonyms
    978 982
     pprNonLinearPatternReason ViewPatternReason = parens (text "view patterns aren't linear")
    
    979 983
     pprNonLinearPatternReason OtherPatternReason = empty
    
    980 984
     
    
    981
    -
    
    982 985
     {- *********************************************************************
    
    983 986
     *                                                                      *
    
    984 987
                  CallStacks and CtOrigin
    

  • compiler/GHC/Types/ThLevelIndex.hs
    ... ... @@ -3,9 +3,10 @@ module GHC.Types.ThLevelIndex where
    3 3
     import GHC.Prelude
    
    4 4
     import GHC.Utils.Outputable
    
    5 5
     import GHC.Types.Basic ( ImportLevel(..) )
    
    6
    -
    
    6
    +import Data.Data (Data)
    
    7
    +import qualified Data.Set as Set
    
    7 8
     -- | The integer which represents the level
    
    8
    -newtype ThLevelIndex = ThLevelIndex Int deriving (Eq, Ord)
    
    9
    +newtype ThLevelIndex = ThLevelIndex Int deriving (Eq, Ord, Data)
    
    9 10
         -- NB: see Note [Template Haskell levels] in GHC.Tc.Gen.Splice
    
    10 11
         -- Incremented when going inside a bracket,
    
    11 12
         -- decremented when going inside a splice
    
    ... ... @@ -32,4 +33,7 @@ quoteLevelIndex = incThLevelIndex topLevelIndex
    32 33
     thLevelIndexFromImportLevel :: ImportLevel -> ThLevelIndex
    
    33 34
     thLevelIndexFromImportLevel NormalLevel = topLevelIndex
    
    34 35
     thLevelIndexFromImportLevel SpliceLevel = spliceLevelIndex
    
    35
    -thLevelIndexFromImportLevel QuoteLevel  = quoteLevelIndex
    \ No newline at end of file
    36
    +thLevelIndexFromImportLevel QuoteLevel  = quoteLevelIndex
    
    37
    +
    
    38
    +pprThBindLevel :: Set.Set ThLevelIndex -> SDoc
    
    39
    +pprThBindLevel levels_set = text "level" <> pluralSet levels_set <+> pprUnquotedSet levels_set
    \ No newline at end of file

  • testsuite/tests/quotes/LiftErrMsg.hs
    1
    +{-# LANGUAGE NoImplicitStagePersistence #-}
    
    2
    +{-# LANGUAGE TemplateHaskellQuotes #-}
    
    3
    +module LiftErrMsg where
    
    4
    +
    
    5
    +import Language.Haskell.TH
    
    6
    +import Language.Haskell.TH.Syntax
    
    7
    +
    
    8
    +data B = B
    
    9
    +
    
    10
    +local_b :: [B]
    
    11
    +local_b = [B]
    
    12
    +
    
    13
    +test :: Q Exp
    
    14
    +test = [| id |]
    
    15
    +
    
    16
    +test2 :: Q Exp
    
    17
    +test2 = [| (id, id) |]
    
    18
    +
    
    19
    +test3 :: Q Exp
    
    20
    +test3 = [| local_b |]
    
    21
    +
    
    22
    +test4 :: a -> Q Exp
    
    23
    +test4 x = [| x |]
    
    24
    +
    
    25
    +test5 :: Lift a => a -> Q Exp
    
    26
    +test5 x = [| x |]
    
    27
    +

  • testsuite/tests/quotes/LiftErrMsg.stderr
    1
    +LiftErrMsg.hs:14:11: error: [GHC-28914]
    
    2
    +    • Level error: ‘id’ is bound at level 0 but used at level 1
    
    3
    +    • Could not be resolved by implicit lifting due to the following error:
    
    4
    +        No instance for: ‘Lift (forall a. a -> a)’
    
    5
    +    • Available from the imports:
    
    6
    +      • imported from ‘Prelude’ at LiftErrMsg.hs:3:8-17
    
    7
    +    • In the expression:
    
    8
    +        [| id |]
    
    9
    +        pending(rn) [implicit lift: id]
    
    10
    +      In an equation for ‘test’:
    
    11
    +          test
    
    12
    +            = [| id |]
    
    13
    +              pending(rn) [implicit lift: id]
    
    14
    +
    
    15
    +LiftErrMsg.hs:20:12: error: [GHC-28914]
    
    16
    +    • Level error: ‘local_b’ is bound at level 0 but used at level 1
    
    17
    +    • Could not be resolved by implicit lifting due to the following error:
    
    18
    +        No instance for: ‘Lift B’
    
    19
    +    • In the expression:
    
    20
    +        [| local_b |]
    
    21
    +        pending(rn) [implicit lift: local_b]
    
    22
    +      In an equation for ‘test3’:
    
    23
    +          test3
    
    24
    +            = [| local_b |]
    
    25
    +              pending(rn) [implicit lift: local_b]
    
    26
    +
    
    27
    +LiftErrMsg.hs:23:14: error: [GHC-28914]
    
    28
    +    • Level error: ‘x’ is bound at level 0 but used at level 1
    
    29
    +    • Could not be resolved by implicit lifting due to the following error:
    
    30
    +        No instance for: ‘Lift a’
    
    31
    +    • In the expression:
    
    32
    +        [| x |]
    
    33
    +        pending(rn) [implicit lift: x]
    
    34
    +      In an equation for ‘test4’:
    
    35
    +          test4 x
    
    36
    +            = [| x |]
    
    37
    +              pending(rn) [implicit lift: x]
    
    38
    +

  • testsuite/tests/quotes/LiftErrMsgDefer.hs
    1
    +{-# LANGUAGE NoImplicitStagePersistence #-}
    
    2
    +{-# LANGUAGE TemplateHaskellQuotes #-}
    
    3
    +module Main where
    
    4
    +
    
    5
    +import Language.Haskell.TH
    
    6
    +import Language.Haskell.TH.Syntax
    
    7
    +
    
    8
    +data B = B
    
    9
    +
    
    10
    +local_b :: [B]
    
    11
    +local_b = [B]
    
    12
    +
    
    13
    +test1 :: Q Exp
    
    14
    +test1 = [| id |]
    
    15
    +
    
    16
    +test2 :: Q Exp
    
    17
    +test2 = [| (id, id) |]
    
    18
    +
    
    19
    +test3 :: Q Exp
    
    20
    +test3 = [| local_b |]
    
    21
    +
    
    22
    +main = do
    
    23
    +  runQ test1
    
    24
    +  runQ test2
    
    25
    +  runQ test3
    
    26
    +  return ()

  • testsuite/tests/quotes/LiftErrMsgDefer.stderr
    1
    +LiftErrMsgDefer: Uncaught exception ghc-internal:GHC.Internal.Control.Exception.Base.TypeError:
    
    2
    +
    
    3
    +LiftErrMsgDefer.hs:14:12: warning: [GHC-28914] [-Wdeferred-type-errors (in -Wdefault)]
    
    4
    +    • Level error: ‘id’ is bound at level 0 but used at level 1
    
    5
    +    • Could not be resolved by implicit lifting due to the following error:
    
    6
    +        No instance for: ‘Lift (forall a. a -> a)’
    
    7
    +    • Available from the imports:
    
    8
    +      • imported from ‘Prelude’ at LiftErrMsgDefer.hs:3:8-11
    
    9
    +    • In the expression:
    
    10
    +        [| id |]
    
    11
    +        pending(rn) [implicit lift: id]
    
    12
    +      In an equation for ‘test1’:
    
    13
    +          test1
    
    14
    +            = [| id |]
    
    15
    +              pending(rn) [implicit lift: id]
    
    16
    +(deferred type error)
    
    17
    +
    
    18
    +HasCallStack backtrace:
    
    19
    +  collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
    
    20
    +  toExceptionWithBacktrace, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:89:42 in ghc-internal:GHC.Internal.Exception
    
    21
    +  throw, called at libraries/ghc-internal/src/GHC/Internal/Control/Exception/Base.hs:435:30 in ghc-internal:GHC.Internal.Control.Exception.Base
    
    22
    +

  • testsuite/tests/quotes/all.T
    ... ... @@ -43,3 +43,5 @@ test('T20893', normal, compile_and_run, [''])
    43 43
     test('T21619', normal, compile, [''])
    
    44 44
     test('T20472_quotes', normal, compile, [''])
    
    45 45
     test('T24750', normal, compile_and_run, [''])
    
    46
    +test('LiftErrMsg', normal, compile_fail, [''])
    
    47
    +test('LiftErrMsgDefer', [exit_code(1)], compile_and_run, ['-fdefer-type-errors'])

  • testsuite/tests/th/TH_Lift.stderr
    1 1
     TH_Lift.hs:18:6-39: Splicing expression
    
    2 2
         (\ x
    
    3 3
            -> [| x |]
    
    4
    -          pending(rn) [<x, lift x>])
    
    4
    +          pending(rn) [implicit lift: x])
    
    5 5
           (5 :: Integer)
    
    6 6
       ======>
    
    7 7
         5
    
    8 8
     TH_Lift.hs:21:6-35: Splicing expression
    
    9 9
         (\ x
    
    10 10
            -> [| x |]
    
    11
    -          pending(rn) [<x, lift x>])
    
    11
    +          pending(rn) [implicit lift: x])
    
    12 12
           (5 :: Int)
    
    13 13
       ======>
    
    14 14
         5
    
    15 15
     TH_Lift.hs:24:7-37: Splicing expression
    
    16 16
         (\ x
    
    17 17
            -> [| x |]
    
    18
    -          pending(rn) [<x, lift x>])
    
    18
    +          pending(rn) [implicit lift: x])
    
    19 19
           (5 :: Int8)
    
    20 20
       ======>
    
    21 21
         5
    
    22 22
     TH_Lift.hs:27:7-38: Splicing expression
    
    23 23
         (\ x
    
    24 24
            -> [| x |]
    
    25
    -          pending(rn) [<x, lift x>])
    
    25
    +          pending(rn) [implicit lift: x])
    
    26 26
           (5 :: Int16)
    
    27 27
       ======>
    
    28 28
         5
    
    29 29
     TH_Lift.hs:30:7-38: Splicing expression
    
    30 30
         (\ x
    
    31 31
            -> [| x |]
    
    32
    -          pending(rn) [<x, lift x>])
    
    32
    +          pending(rn) [implicit lift: x])
    
    33 33
           (5 :: Int32)
    
    34 34
       ======>
    
    35 35
         5
    
    36 36
     TH_Lift.hs:33:7-38: Splicing expression
    
    37 37
         (\ x
    
    38 38
            -> [| x |]
    
    39
    -          pending(rn) [<x, lift x>])
    
    39
    +          pending(rn) [implicit lift: x])
    
    40 40
           (5 :: Int64)
    
    41 41
       ======>
    
    42 42
         5
    
    43 43
     TH_Lift.hs:36:6-36: Splicing expression
    
    44 44
         (\ x
    
    45 45
            -> [| x |]
    
    46
    -          pending(rn) [<x, lift x>])
    
    46
    +          pending(rn) [implicit lift: x])
    
    47 47
           (5 :: Word)
    
    48 48
       ======>
    
    49 49
         5
    
    50 50
     TH_Lift.hs:39:6-37: Splicing expression
    
    51 51
         (\ x
    
    52 52
            -> [| x |]
    
    53
    -          pending(rn) [<x, lift x>])
    
    53
    +          pending(rn) [implicit lift: x])
    
    54 54
           (5 :: Word8)
    
    55 55
       ======>
    
    56 56
         5
    
    57 57
     TH_Lift.hs:42:6-38: Splicing expression
    
    58 58
         (\ x
    
    59 59
            -> [| x |]
    
    60
    -          pending(rn) [<x, lift x>])
    
    60
    +          pending(rn) [implicit lift: x])
    
    61 61
           (5 :: Word16)
    
    62 62
       ======>
    
    63 63
         5
    
    64 64
     TH_Lift.hs:45:6-38: Splicing expression
    
    65 65
         (\ x
    
    66 66
            -> [| x |]
    
    67
    -          pending(rn) [<x, lift x>])
    
    67
    +          pending(rn) [implicit lift: x])
    
    68 68
           (5 :: Word32)
    
    69 69
       ======>
    
    70 70
         5
    
    71 71
     TH_Lift.hs:48:6-38: Splicing expression
    
    72 72
         (\ x
    
    73 73
            -> [| x |]
    
    74
    -          pending(rn) [<x, lift x>])
    
    74
    +          pending(rn) [implicit lift: x])
    
    75 75
           (5 :: Word64)
    
    76 76
       ======>
    
    77 77
         5
    
    78 78
     TH_Lift.hs:51:7-40: Splicing expression
    
    79 79
         (\ x
    
    80 80
            -> [| x |]
    
    81
    -          pending(rn) [<x, lift x>])
    
    81
    +          pending(rn) [implicit lift: x])
    
    82 82
           (5 :: Natural)
    
    83 83
       ======>
    
    84 84
         5
    
    85 85
     TH_Lift.hs:54:6-44: Splicing expression
    
    86 86
         (\ x
    
    87 87
            -> [| x |]
    
    88
    -          pending(rn) [<x, lift x>])
    
    88
    +          pending(rn) [implicit lift: x])
    
    89 89
           (5 % 3 :: Rational)
    
    90 90
       ======>
    
    91 91
         1.6666666666666667
    
    92 92
     TH_Lift.hs:57:7-39: Splicing expression
    
    93 93
         (\ x
    
    94 94
            -> [| x |]
    
    95
    -          pending(rn) [<x, lift x>])
    
    95
    +          pending(rn) [implicit lift: x])
    
    96 96
           (pi :: Float)
    
    97 97
       ======>
    
    98 98
         3.1415927410125732
    
    99 99
     TH_Lift.hs:60:7-40: Splicing expression
    
    100 100
         (\ x
    
    101 101
            -> [| x |]
    
    102
    -          pending(rn) [<x, lift x>])
    
    102
    +          pending(rn) [implicit lift: x])
    
    103 103
           (pi :: Double)
    
    104 104
       ======>
    
    105 105
         3.141592653589793
    
    106 106
     TH_Lift.hs:63:6-28: Splicing expression
    
    107 107
         (\ x
    
    108 108
            -> [| x |]
    
    109
    -          pending(rn) [<x, lift x>])
    
    109
    +          pending(rn) [implicit lift: x])
    
    110 110
           'x'
    
    111 111
       ======>
    
    112 112
         'x'
    
    113 113
     TH_Lift.hs:66:6-29: Splicing expression
    
    114 114
         (\ x
    
    115 115
            -> [| x |]
    
    116
    -          pending(rn) [<x, lift x>])
    
    116
    +          pending(rn) [implicit lift: x])
    
    117 117
           True
    
    118 118
       ======>
    
    119 119
         True
    
    120 120
     TH_Lift.hs:69:6-35: Splicing expression
    
    121 121
         (\ x
    
    122 122
            -> [| x |]
    
    123
    -          pending(rn) [<x, lift x>])
    
    123
    +          pending(rn) [implicit lift: x])
    
    124 124
           (Just 'x')
    
    125 125
       ======>
    
    126 126
         Just 'x'
    
    127 127
     TH_Lift.hs:72:6-58: Splicing expression
    
    128 128
         (\ x
    
    129 129
            -> [| x |]
    
    130
    -          pending(rn) [<x, lift x>])
    
    130
    +          pending(rn) [implicit lift: x])
    
    131 131
           (Right False :: Either Char Bool)
    
    132 132
       ======>
    
    133 133
         Right False
    
    134 134
     TH_Lift.hs:75:6-29: Splicing expression
    
    135 135
         (\ x
    
    136 136
            -> [| x |]
    
    137
    -          pending(rn) [<x, lift x>])
    
    137
    +          pending(rn) [implicit lift: x])
    
    138 138
           "hi!"
    
    139 139
       ======>
    
    140 140
         "hi!"
    
    141 141
     TH_Lift.hs:78:6-27: Splicing expression
    
    142 142
         (\ x
    
    143 143
            -> [| x |]
    
    144
    -          pending(rn) [<x, lift x>])
    
    144
    +          pending(rn) [implicit lift: x])
    
    145 145
           ()
    
    146 146
       ======>
    
    147 147
         ()
    
    148 148
     TH_Lift.hs:81:6-46: Splicing expression
    
    149 149
         (\ x
    
    150 150
            -> [| x |]
    
    151
    -          pending(rn) [<x, lift x>])
    
    151
    +          pending(rn) [implicit lift: x])
    
    152 152
           (True, 'x', 4 :: Int)
    
    153 153
       ======>
    
    154 154
         (,,) True 'x' 4
    
    155 155
     TH_Lift.hs:84:6-41: Splicing expression
    
    156 156
         (\ x
    
    157 157
            -> [| x |]
    
    158
    -          pending(rn) [<x, lift x>])
    
    158
    +          pending(rn) [implicit lift: x])
    
    159 159
           ('a' :| "bcde")
    
    160 160
       ======>
    
    161 161
         (:|) 'a' "bcde"