Magnus pushed to branch wip/mangoiv/26616 at Glasgow Haskell Compiler / GHC

Commits:

25 changed files:

Changes:

  • changelog.d/26616
    1
    +section: compiler
    
    2
    +synopsis: Fix bugs with ExplcitLevelImports accepting incorrect qualified imports and reporting errors
    
    3
    +  incorrectly in the presence of qualified imports
    
    4
    +description: When reporting errors, ExplcitLevelImports would sometimes report identifiers qualified at a
    
    5
    +  module they were not oringally actually be qualified at. It would also allow using *any* qualified import
    
    6
    +  to bring an identifier into scope, even if that qualified import was not imported at the correct level.
    
    7
    +  This MR fixes both issues by passing more information to the responsible error reporting code.
    
    8
    +mrs: !16195
    
    9
    +issues: #26616 #27385

  • compiler/GHC/Rename/Env.hs
    ... ... @@ -12,9 +12,9 @@ module GHC.Rename.Env (
    12 12
     
    
    13 13
             lookupLocatedTopBndrRnN, lookupTopBndrRn,
    
    14 14
     
    
    15
    -        lookupLocatedOccRn, lookupLocatedOccRnConstr, lookupLocatedOccRnRecField,
    
    15
    +        lookupLocatedOccRn, lookupLocatedOccRnGre, lookupLocatedOccRnConstr, lookupLocatedOccRnRecField,
    
    16 16
             lookupLocatedOccRnNone,
    
    17
    -        lookupOccRn, lookupOccRn_maybe, lookupSameOccRn_maybe,
    
    17
    +        lookupOccRn, lookupOccRnGre, lookupOccRn_maybe, lookupSameOccRn_maybe,
    
    18 18
             lookupLocalOccRn_maybe, lookupInfoOccRn,
    
    19 19
             lookupLocalOccThLvl_maybe, lookupLocalOccRn,
    
    20 20
             lookupTypeOccRn,
    
    ... ... @@ -992,6 +992,11 @@ lookupLocatedOccRn :: WhatLooking
    992 992
                        -> TcRn (GenLocated (EpAnn ann) Name)
    
    993 993
     lookupLocatedOccRn what = wrapLocMA (lookupOccRn what)
    
    994 994
     
    
    995
    +lookupLocatedOccRnGre :: WhatLooking
    
    996
    +                      -> GenLocated (EpAnn ann) RdrName
    
    997
    +                      -> TcRn (GenLocated (EpAnn ann) GlobalRdrElt)
    
    998
    +lookupLocatedOccRnGre what = wrapLocMA (lookupOccRnGre what)
    
    999
    +
    
    995 1000
     lookupLocatedOccRnConstr :: GenLocated (EpAnn ann) RdrName
    
    996 1001
                              -> TcRn (GenLocated (EpAnn ann) Name)
    
    997 1002
     lookupLocatedOccRnConstr = wrapLocMA lookupOccRnConstr
    
    ... ... @@ -1019,11 +1024,14 @@ lookupLocalOccThLvl_maybe name
    1019 1024
     -- | lookupOccRn looks up an occurrence of a RdrName, and uses its argument to
    
    1020 1025
     -- determine what kind of suggestions should be displayed if it is not in scope
    
    1021 1026
     lookupOccRn :: WhatLooking -> RdrName -> RnM Name
    
    1022
    -lookupOccRn which_suggest rdr_name
    
    1027
    +lookupOccRn which_suggest = fmap greName . lookupOccRnGre which_suggest
    
    1028
    +
    
    1029
    +lookupOccRnGre :: WhatLooking -> RdrName -> RnM GlobalRdrElt
    
    1030
    +lookupOccRnGre which_suggest rdr_name
    
    1023 1031
       = do { mb_gre <- lookupOccRn_maybe rdr_name
    
    1024 1032
            ; case mb_gre of
    
    1025
    -           Just gre  -> return $ greName gre
    
    1026
    -           Nothing   -> reportUnboundName which_suggest rdr_name }
    
    1033
    +           Just gre  -> return gre
    
    1034
    +           Nothing   -> mkUnboundGRERdr rdr_name <$ reportUnboundName which_suggest rdr_name }
    
    1027 1035
     
    
    1028 1036
     -- | Look up an occurrence of a 'RdrName'.
    
    1029 1037
     --
    
    ... ... @@ -1087,16 +1095,16 @@ lookupLocalOccRn rdr_name
    1087 1095
     
    
    1088 1096
     -- lookupTypeOccRn looks up an optionally promoted RdrName.
    
    1089 1097
     -- Used for looking up type variables.
    
    1090
    -lookupTypeOccRn :: RdrName -> RnM Name
    
    1098
    +lookupTypeOccRn :: RdrName -> RnM (MayGRE GREInfo)
    
    1091 1099
     -- see Note [Demotion]
    
    1092 1100
     lookupTypeOccRn rdr_name
    
    1093 1101
       = do { mb_gre <- lookupOccRn_maybe rdr_name
    
    1094 1102
            ; case mb_gre of
    
    1095
    -             Just gre -> return $ greName gre
    
    1103
    +             Just gre -> return $ Right $! gre
    
    1096 1104
                  Nothing   ->
    
    1097 1105
                    if occName rdr_name == occName eqTyCon_RDR -- See Note [eqTyCon (~) compatibility fallback]
    
    1098
    -               then eqTyConName <$ addDiagnostic TcRnTypeEqualityOutOfScope
    
    1099
    -               else lookup_demoted rdr_name }
    
    1106
    +               then (Left $! eqTyConName) <$ addDiagnostic TcRnTypeEqualityOutOfScope
    
    1107
    +               else Left <$!> lookup_demoted rdr_name }
    
    1100 1108
     
    
    1101 1109
     {- Note [eqTyCon (~) compatibility fallback]
    
    1102 1110
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

  • compiler/GHC/Rename/Expr.hs
    1 1
     {-# LANGUAGE CPP                 #-}
    
    2 2
     {-# LANGUAGE MonadComprehensions #-}
    
    3 3
     {-# LANGUAGE MultiWayIf          #-}
    
    4
    -{-# LANGUAGE RecordWildCards #-}
    
    5 4
     {-# LANGUAGE TypeFamilies        #-}
    
    6 5
     {-# LANGUAGE ViewPatterns        #-}
    
    7 6
     
    
    ... ... @@ -321,7 +320,7 @@ rnExpr (HsVar _ (L l v))
    321 320
                 -- matching GRE and add a name clash error
    
    322 321
                 -- (see lookupGlobalOccRn_overloaded, called by lookupExprOccRn).
    
    323 322
                 -> do { let sel_name = flSelector $ recFieldLabel fld_info
    
    324
    -                  ; checkThLocalNameNoLift (L (l2l l) (WithUserRdr v sel_name))
    
    323
    +                  ; checkThLocalNameNoLift (L l $ WithUserRdr v $ Right $! gre)
    
    325 324
                       ; return (XExpr (HsRecSelRn (FieldOcc v  (L l sel_name))), unitFN sel_name)
    
    326 325
                       }
    
    327 326
                 | nm == nilDataConName
    
    ... ... @@ -332,7 +331,7 @@ rnExpr (HsVar _ (L l v))
    332 331
                 -> rnExpr (ExplicitList noAnn [])
    
    333 332
     
    
    334 333
                 | otherwise
    
    335
    -            -> do { res_expr <- checkThLocalNameWithLift (L (l2l l) (WithUserRdr v nm))
    
    334
    +            -> do { res_expr <- checkThLocalNameWithLift (L (l2l l) (WithUserRdr v $ Right $! gre))
    
    336 335
                       ; return (res_expr, unitFN nm) }
    
    337 336
             }}}
    
    338 337
     
    

  • compiler/GHC/Rename/HsType.hs
    ... ... @@ -606,20 +606,21 @@ rnHsTyKi env tv@(HsTyVar _ ip (L loc rdr_name))
    606 606
              TcRnUnexpectedKindVar rdr_name
    
    607 607
                -- Any type variable at the kind level is illegal without the use
    
    608 608
                -- of PolyKinds (see #14710)
    
    609
    -       ; name <- rnTyVar env rdr_name
    
    609
    +       ; mgre <- rnTyVar env rdr_name
    
    610 610
            ; this_mod <- getModule
    
    611 611
            ; explicit_level_imports <- xoptM LangExt.ExplicitLevelImports
    
    612
    -       ; let loc_name_with_rdr = L loc $ WithUserRdr rdr_name name
    
    612
    +       ; let loc_mgre_with_rdr = L loc $ WithUserRdr rdr_name mgre
    
    613
    +             name = mgreName mgre
    
    613 614
            ; if  | explicit_level_imports
    
    614 615
                  -- See Note [Strict level checks with ExplicitLevelImports]
    
    615
    -             -> checkThLocalNameNoLift loc_name_with_rdr
    
    616
    +             -> checkThLocalNameNoLift loc_mgre_with_rdr
    
    616 617
     
    
    617 618
                  | nameIsLocalOrFrom this_mod name
    
    618
    -             -> checkThLocalTyName name
    
    619
    +             -> checkThLocalTyName mgre
    
    619 620
     
    
    620 621
                  | otherwise -> pure ()
    
    621
    -       ; checkPromotedDataConName env tv Prefix ip name
    
    622
    -       ; return (HsTyVar noAnn ip loc_name_with_rdr, unitFN name) }
    
    622
    +       ; checkPromotedDataConName env tv Prefix ip $ mgreName mgre
    
    623
    +       ; return (HsTyVar noAnn ip $ fmap mgreName <$> loc_mgre_with_rdr, unitFN name) }
    
    623 624
     
    
    624 625
     rnHsTyKi env ty@(HsOpTy _ ty1 tyop ty2)
    
    625 626
       = setSrcSpan (getLocA tyop) $
    
    ... ... @@ -826,13 +827,13 @@ throw an error accordingly.
    826 827
     -}
    
    827 828
     
    
    828 829
     --------------
    
    829
    -rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name
    
    830
    +rnTyVar :: RnTyKiEnv -> RdrName -> RnM (MayGRE GREInfo)
    
    830 831
     rnTyVar env rdr_name
    
    831
    -  = do { name <- lookupTypeOccRn rdr_name
    
    832
    -       ; checkNamedWildCard env name
    
    833
    -       ; return name }
    
    832
    +  = do { mgre <- lookupTypeOccRn rdr_name
    
    833
    +       ; checkNamedWildCard env $ mgreName mgre
    
    834
    +       ; return mgre }
    
    834 835
     
    
    835
    -rnLTyVar :: LocatedN RdrName -> RnM (LocatedN Name)
    
    836
    +rnLTyVar :: LocatedN RdrName -> RnM (LocatedN (MayGRE GREInfo))
    
    836 837
     -- Called externally; does not deal with wildcards
    
    837 838
     rnLTyVar (L loc rdr_name)
    
    838 839
       = do { tyvar <- lookupTypeOccRn rdr_name
    
    ... ... @@ -843,14 +844,15 @@ rnHsTyOp :: RnTyKiEnv -> HsType GhcPs -> LHsType GhcPs
    843 844
              -> RnM (LHsType GhcRn, FreeNames)
    
    844 845
     rnHsTyOp env overall_ty tyop
    
    845 846
       | L l (HsTyVar ann prom (L loc op)) <- tyop
    
    846
    -  = do { op' <- rnTyVar env op
    
    847
    +  = do { opmgre <- rnTyVar env op
    
    848
    +       ; let opName = mgreName opmgre
    
    847 849
            ; unlessXOptM LangExt.TypeOperators $
    
    848
    -           if (op' `hasKey` eqTyConKey) -- See [eqTyCon (~) compatibility fallback] in GHC.Rename.Env
    
    850
    +           if opName `hasKey` eqTyConKey -- See [eqTyCon (~) compatibility fallback] in GHC.Rename.Env
    
    849 851
                then addDiagnostic TcRnTypeEqualityRequiresOperators
    
    850 852
                else addErr $ TcRnIllegalTypeOperator (ppr overall_ty) op
    
    851
    -       ; checkPromotedDataConName env overall_ty Infix prom op'
    
    852
    -       ; let tyop' = L l (HsTyVar ann prom (L loc (WithUserRdr op op')))
    
    853
    -       ; return (tyop', unitFN op') }
    
    853
    +       ; checkPromotedDataConName env overall_ty Infix prom opName
    
    854
    +       ; let tyop' = L l (HsTyVar ann prom (L loc (WithUserRdr op opName)))
    
    855
    +       ; return (tyop', unitFN opName) }
    
    854 856
       | otherwise
    
    855 857
       = rnLHsTyKi env tyop
    
    856 858
     
    

  • compiler/GHC/Rename/Module.hs
    ... ... @@ -2491,8 +2491,8 @@ rnInjectivityAnn tvBndrs (L _ (TyVarSig _ resTv))
    2491 2491
                  bindLocalNames (maybeToList (hsLTyVarName resTv)) $
    
    2492 2492
                  -- The return type variable scopes over the injectivity annotation
    
    2493 2493
                  -- e.g.   type family F a = (r::*) | r -> a
    
    2494
    -             do { injFrom' <- rnLTyVar injFrom
    
    2495
    -                ; injTo'   <- mapM rnLTyVar injTo
    
    2494
    +             do { injFrom' <- fmap mgreName <$> rnLTyVar injFrom
    
    2495
    +                ; injTo'   <- mapM (fmap (fmap mgreName) . rnLTyVar) injTo
    
    2496 2496
                     -- Note: srcSpan is unchanged, but typechecker gets
    
    2497 2497
                     -- confused, l2l call makes it happy
    
    2498 2498
                     ; return $ L (l2l srcSpan) (InjectivityAnn x injFrom' injTo') }
    
    ... ... @@ -2533,7 +2533,7 @@ rnInjectivityAnn _ _ (L srcSpan (InjectivityAnn x injFrom injTo)) =
    2533 2533
        (injDecl', _) <- askNoErrs $ do
    
    2534 2534
          injFrom' <- rnLTyVar injFrom
    
    2535 2535
          injTo'   <- mapM rnLTyVar injTo
    
    2536
    -     return $ L srcSpan (InjectivityAnn x injFrom' injTo')
    
    2536
    +     return $ L srcSpan (InjectivityAnn x (fmap mgreName injFrom') (fmap (fmap mgreName) injTo'))
    
    2537 2537
        return $ injDecl'
    
    2538 2538
     
    
    2539 2539
     {-
    

  • compiler/GHC/Rename/Pat.hs
    ... ... @@ -1296,7 +1296,8 @@ wrapSrcSpanTPRnM fn (L loc a) = do
    1296 1296
     
    
    1297 1297
     lookupTypeOccTPRnM :: RdrName -> TPRnM Name
    
    1298 1298
     lookupTypeOccTPRnM rdr_name = liftRnFV $ do
    
    1299
    -  name <- lookupTypeOccRn rdr_name
    
    1299
    +  mgre <- lookupTypeOccRn rdr_name
    
    1300
    +  let name = mgreName mgre
    
    1300 1301
       pure (name, unitFN name)
    
    1301 1302
     
    
    1302 1303
     rn_lty_pat :: LHsType GhcPs -> TPRnM (LHsType GhcRn)
    

  • compiler/GHC/Rename/Splice.hs
    1 1
     {-# LANGUAGE TypeFamilies #-}
    
    2
    -{-# LANGUAGE MultiWayIf #-}
    
    3 2
     
    
    4 3
     module GHC.Rename.Splice (
    
    5 4
             rnTopSpliceDecls,
    
    ... ... @@ -40,7 +39,7 @@ import GHC.Unit.Module
    40 39
     import GHC.Types.SrcLoc
    
    41 40
     import GHC.Rename.HsType ( rnLHsType )
    
    42 41
     
    
    43
    -import Control.Monad    ( unless, when )
    
    42
    +import Control.Monad    ( unless, when, void )
    
    44 43
     
    
    45 44
     import {-# SOURCE #-} GHC.Rename.Expr ( rnLExpr )
    
    46 45
     
    
    ... ... @@ -182,11 +181,13 @@ rnUntypedBracket e br_body
    182 181
     
    
    183 182
     rn_utbracket :: HsQuote GhcPs -> RnM (HsQuote GhcRn, FreeNames)
    
    184 183
     rn_utbracket (VarBr _ is_value_name rdr_name)
    
    185
    -  = do { name <- lookupOccRn (if is_value_name then WL_Term else WL_Type) (unLoc rdr_name)
    
    186
    -       ; let res_name = L (l2l (locA rdr_name)) (WithUserRdr (unLoc rdr_name) name)
    
    187
    -       ; if is_value_name then checkThLocalNameNoLift res_name else checkThLocalTyName name
    
    188
    -       ; check_namespace is_value_name name
    
    189
    -       ; return (VarBr noExtField is_value_name (noLocA name), unitFN name) }
    
    184
    +  = do { gre <- lookupOccRnGre (if is_value_name then WL_Term else WL_Type) (unLoc rdr_name)
    
    185
    +       ; let mgre = Right $! gre
    
    186
    +       ; let res_name = L (l2l (locA rdr_name)) (WithUserRdr (unLoc rdr_name) mgre)
    
    187
    +       ; let name = greName gre
    
    188
    +       ; if is_value_name then checkThLocalNameNoLift res_name else checkThLocalTyName mgre
    
    189
    +       ; check_namespace is_value_name $ greName gre
    
    190
    +       ; return (VarBr noExtField is_value_name (fmap (mgreName . unwrapUserRdr) res_name), unitFN name) }
    
    190 191
     
    
    191 192
     rn_utbracket (ExpBr _ e) = do { (e', fvs) <- rnLExpr e
    
    192 193
                                     ; return (ExpBr noExtField e', fvs) }
    
    ... ... @@ -431,10 +432,11 @@ rnUntypedSplice (HsUntypedSpliceExpr _ expr) flavour
    431 432
     
    
    432 433
     rnUntypedSplice (HsQuasiQuote _ quoter quote) flavour
    
    433 434
       = do  { -- Rename the quoter; akin to the HsVar case of rnExpr
    
    434
    -        ; quoter' <- lookupLocatedOccRn WL_TermVariable quoter
    
    435
    -        ; let res_name = WithUserRdr (unLoc quoter) <$> quoter'
    
    435
    +        ; quoter' <- lookupLocatedOccRnGre WL_TermVariable quoter
    
    436
    +        ; let res_name = WithUserRdr (unLoc quoter) . (Right $!) <$> quoter'
    
    436 437
             ; checkThLocalNameNoLift res_name
    
    437
    -        ; return (HsQuasiQuote (HsQuasiQuoteExt flavour) quoter' quote, unitFN (unLoc quoter')) }
    
    438
    +        ; let loc_name = fmap greName quoter'
    
    439
    +        ; return (HsQuasiQuote (HsQuasiQuoteExt flavour) loc_name quote, unitFN (unLoc loc_name)) }
    
    438 440
     
    
    439 441
     ---------------------
    
    440 442
     rnTypedSplice :: HsTypedSplice GhcPs -- Typed splice expression
    
    ... ... @@ -907,14 +909,14 @@ traceSplice (SpliceInfo { spliceDescription = sd, spliceSource = mb_src
    907 909
           = vcat [ text "--" <+> ppr loc <> colon <+> text "Splicing" <+> text sd
    
    908 910
                  , gen ]
    
    909 911
     
    
    910
    -checkThLocalTyName :: Name -> RnM ()
    
    911
    -checkThLocalTyName name
    
    912
    +checkThLocalTyName :: MayGRE w -> RnM ()
    
    913
    +checkThLocalTyName mgre
    
    912 914
       | isUnboundName name   -- Do not report two errors for
    
    913 915
       = return ()            --   $(not_in_scope args)
    
    914 916
     
    
    915 917
       | otherwise
    
    916 918
       = do  { traceRn "checkThLocalTyName" (ppr name)
    
    917
    -        ; mb_local_use <- getCurrentAndBindLevel name
    
    919
    +        ; mb_local_use <- getCurrentAndBindLevel mgre
    
    918 920
             ; case mb_local_use of {
    
    919 921
                  Nothing -> return () ;  -- Not a locally-bound thing
    
    920 922
                  Just (top_lvl, bind_lvl, use_lvl) ->
    
    ... ... @@ -932,28 +934,29 @@ checkThLocalTyName name
    932 934
                                                      <+> ppr use_lvl)
    
    933 935
             ; dflags <- getDynFlags
    
    934 936
             ; checkCrossLevelLiftingTy dflags top_lvl bind_lvl use_lvl name } } }
    
    937
    +  where name = mgreName mgre
    
    935 938
     
    
    936 939
     -- | Check whether we are allowed to use a Name in this context (for TH purposes)
    
    937 940
     -- In the case of a level incorrect program, attempt to fix it by using
    
    938 941
     -- a Lift constraint.
    
    939
    -checkThLocalNameWithLift :: LIdOccP GhcRn -> RnM (HsExpr GhcRn)
    
    942
    +checkThLocalNameWithLift :: LocatedN (WithUserRdr (MayGRE GREInfo)) -> RnM (HsExpr GhcRn)
    
    940 943
     checkThLocalNameWithLift = checkThLocalName True
    
    941 944
     
    
    942 945
     -- | Check whether we are allowed to use a Name in this context (for TH purposes)
    
    943 946
     -- In the case of a level incorrect program, do not attempt to fix it by using
    
    944 947
     -- a Lift constraint.
    
    945
    -checkThLocalNameNoLift :: LIdOccP GhcRn -> RnM ()
    
    946
    -checkThLocalNameNoLift name = checkThLocalName False name >> return ()
    
    948
    +checkThLocalNameNoLift :: LocatedN (WithUserRdr (MayGRE GREInfo)) -> RnM ()
    
    949
    +checkThLocalNameNoLift = void . checkThLocalName False
    
    947 950
     
    
    948 951
     -- | Implementation of the level checks
    
    949 952
     -- See Note [Template Haskell levels]
    
    950
    -checkThLocalName :: Bool -> LIdOccP GhcRn -> RnM (HsExpr GhcRn)
    
    951
    -checkThLocalName allow_lifting name_var
    
    953
    +checkThLocalName :: Bool -> LocatedN (WithUserRdr (MayGRE GREInfo)) -> RnM (HsExpr GhcRn)
    
    954
    +checkThLocalName allow_lifting mgre
    
    952 955
       -- Exact and Orig names are not imported, so presumed available at all levels.
    
    953 956
       -- whenever the user uses exact names, e.g. say @'mkNameG_v' "" "Foo" "bar"@,
    
    954 957
       -- even though the 'mkNameG_v' here is essentially a quotation, we do not do
    
    955 958
       -- level checks as we assume that the user was trying to bypass the level checks
    
    956
    -  | isExact (userRdrName (unLoc name_var)) || isOrig (userRdrName (unLoc name_var))
    
    959
    +  | isExact rdr || isOrig rdr
    
    957 960
       = return (HsVar noExtField name_var)
    
    958 961
       | isUnboundName name                  -- Do not report two errors for
    
    959 962
       = return (HsVar noExtField name_var)  --   $(not_in_scope args)
    
    ... ... @@ -961,7 +964,7 @@ checkThLocalName allow_lifting name_var
    961 964
       = return (HsVar noExtField name_var)
    
    962 965
       | otherwise
    
    963 966
       = do  {
    
    964
    -          mb_local_use <- getCurrentAndBindLevel name
    
    967
    +          mb_local_use <- getCurrentAndBindLevel $ unwrap mgre
    
    965 968
             ; case mb_local_use of {
    
    966 969
                  Nothing -> return (HsVar noExtField name_var) ;  -- Not a locally-bound thing
    
    967 970
                  Just (top_lvl, bind_lvl, use_lvl) ->
    
    ... ... @@ -969,13 +972,12 @@ checkThLocalName allow_lifting name_var
    969 972
             ; let is_local
    
    970 973
                       | Just mod <- nameModule_maybe name = mod == cur_mod
    
    971 974
                       | otherwise = True
    
    972
    -        ; traceRn "checkThLocalName" (ppr name <+> ppr bind_lvl <+> ppr use_lvl)
    
    973 975
             ; dflags <- getDynFlags
    
    974
    -        ; env <- getGlobalRdrEnv
    
    975
    -        ; let mgre = lookupGRE_Name env name
    
    976
    -        ; checkCrossLevelLifting dflags (LevelCheckSplice name mgre) top_lvl is_local allow_lifting bind_lvl use_lvl name_var } } }
    
    977
    -  where
    
    978
    -    name = getName name_var
    
    976
    +        ; checkCrossLevelLifting dflags (LevelCheckSplice $ unLoc mgre) top_lvl is_local allow_lifting bind_lvl use_lvl name_var } } }
    
    977
    +  where rdr = userRdrName $ unLoc name_var
    
    978
    +        name_var = fmap mgreName <$> mgre
    
    979
    +        name = unwrap name_var
    
    980
    +        unwrap = unwrapUserRdr . unLoc
    
    979 981
     
    
    980 982
     --------------------------------------
    
    981 983
     checkCrossLevelLifting :: DynFlags
    
    ... ... @@ -1013,9 +1015,12 @@ checkCrossLevelLifting dflags reason top_lvl_flg is_local allow_lifting bind_lvl
    1013 1015
       , any (\bind_idx -> use_lvl_idx == incThLevelIndex bind_idx) (Set.toList bind_lvl)
    
    1014 1016
       , allow_lifting
    
    1015 1017
       = do
    
    1016
    -       let mgre = case reason of
    
    1017
    -                   LevelCheckSplice _ gre -> gre
    
    1018
    -                   _ -> Nothing
    
    1018
    +       let mgre
    
    1019
    +             | LevelCheckSplice rdr <- reason
    
    1020
    +             , Right gre <- unwrapUserRdr rdr
    
    1021
    +               = Just $! gre
    
    1022
    +             | otherwise
    
    1023
    +               = Nothing
    
    1019 1024
            (splice_name :: Name) <- newLocalBndrRn (noLocA unqualSplice)
    
    1020 1025
            let  pend_splice :: HsImplicitLiftSplice
    
    1021 1026
                 pend_splice = HsImplicitLiftSplice bind_lvl use_lvl_idx mgre name_var
    

  • compiler/GHC/Rename/Splice.hs-boot
    ... ... @@ -2,7 +2,7 @@ module GHC.Rename.Splice where
    2 2
     
    
    3 3
     import GHC.Hs
    
    4 4
     import GHC.Tc.Utils.Monad
    
    5
    -import GHC.Types.Name (Name)
    
    5
    +import GHC.Types.Name.Reader (WithUserRdr, GREInfo)
    
    6 6
     import GHC.Types.Name.Set
    
    7 7
     
    
    8 8
     
    
    ... ... @@ -15,6 +15,6 @@ rnSpliceDecl :: SpliceDecl GhcPs -> RnM (SpliceDecl GhcRn, FreeNames)
    15 15
     
    
    16 16
     rnTopSpliceDecls :: HsUntypedSplice GhcPs -> RnM ([LHsDecl GhcPs], FreeNames)
    
    17 17
     
    
    18
    -checkThLocalTyName :: Name -> RnM ()
    
    18
    +checkThLocalTyName :: MayGRE w -> RnM ()
    
    19 19
     
    
    20
    -checkThLocalNameNoLift :: LIdOccP GhcRn -> RnM ()
    20
    +checkThLocalNameNoLift :: LocatedN (WithUserRdr (MayGRE GREInfo)) -> RnM ()

  • compiler/GHC/Tc/Errors.hs
    ... ... @@ -1188,8 +1188,13 @@ mkImplicitLiftingReporter ctxt
    1188 1188
         mkImplicitLiftingError :: ErrorItem -> TcRnMessage
    
    1189 1189
         mkImplicitLiftingError item =
    
    1190 1190
           case errorItemOrigin item of
    
    1191
    -        ImplicitLiftOrigin (HsImplicitLiftSplice bound used gre name) ->
    
    1192
    -          TcRnBadlyLevelled (LevelCheckSplice (getName name) gre) bound used (Just item) (cec_defer_type_errors ctxt)
    
    1191
    +        ImplicitLiftOrigin (HsImplicitLiftSplice bound used mgre loc_name) ->
    
    1192
    +          TcRnBadlyLevelled
    
    1193
    +            (LevelCheckSplice $ maybe (Left $! getName loc_name) (Right $!) mgre <$ unLoc loc_name)
    
    1194
    +            bound
    
    1195
    +            used
    
    1196
    +            (Just item)
    
    1197
    +            (cec_defer_type_errors ctxt)
    
    1193 1198
             _ -> pprPanic "mkImplicitLiftingError" (ppr item)
    
    1194 1199
     
    
    1195 1200
     mkGivenErrorReporter :: Reporter
    

  • compiler/GHC/Tc/Errors/Ppr.hs
    ... ... @@ -3465,12 +3465,16 @@ pprTcRnBadlyLevelled reason bind_lvls use_lvl lift_attempt = mkDecorated $
    3465 3465
               (text "No instance for:" <+> quotes (ppr (errorItemPred item)))
    
    3466 3466
              | Just item <- [lift_attempt]
    
    3467 3467
              ] ++
    
    3468
    -         [ vcat (text "Available from the imports:" : ppr_imports (gre_imp gre))
    
    3469
    -         | LevelCheckSplice _ (Just gre) <- [reason]
    
    3468
    +         [ ppr_imports (gre_imp gre)
    
    3469
    +         | LevelCheckSplice (unwrapUserRdr -> Right gre) <- [reason]
    
    3470 3470
              , not (isEmptyBag (gre_imp gre)) ]
    
    3471 3471
       where
    
    3472
    -    ppr_imports :: Bag ImportSpec -> [SDoc]
    
    3473
    -    ppr_imports = map ((bullet <+>) . ppr ) . bagToList
    
    3472
    +    ppr_imports :: Bag ImportSpec -> SDoc
    
    3473
    +    ppr_imports bag
    
    3474
    +      | [imp] <- impspecs = pprImpSpec imp
    
    3475
    +      | otherwise = vcat $ text "Available from the imports:" : map ((bullet <+>) .  pprImpSpec) impspecs
    
    3476
    +      where impspecs = bagToList bag
    
    3477
    +    pprImpSpec imp = ppr imp
    
    3474 3478
     
    
    3475 3479
     note :: SDoc -> SDoc
    
    3476 3480
     note note = "Note" <> colon <+> note <> dot
    
    ... ... @@ -6250,8 +6254,8 @@ pprLevelCheckReason :: LevelCheckReason -> SDoc
    6250 6254
     pprLevelCheckReason = \case
    
    6251 6255
       LevelCheckInstance _ t ->
    
    6252 6256
         text "instance for" <+> quotes (ppr t)
    
    6253
    -  LevelCheckSplice t _ ->
    
    6254
    -    quotes (ppr t)
    
    6257
    +  LevelCheckSplice t ->
    
    6258
    +    quotes $ ppr $ userRdrName t
    
    6255 6259
     
    
    6256 6260
     pprUninferrableTyVarCtx :: UninferrableTyVarCtx -> SDoc
    
    6257 6261
     pprUninferrableTyVarCtx = \case
    

  • compiler/GHC/Tc/Errors/Types.hs
    ... ... @@ -6338,7 +6338,7 @@ data WrongThingSort
    6338 6338
     
    
    6339 6339
     data LevelCheckReason
    
    6340 6340
       = LevelCheckInstance !InstanceWhat !PredType
    
    6341
    -  | LevelCheckSplice !Name !(Maybe GlobalRdrElt)
    
    6341
    +  | LevelCheckSplice !(WithUserRdr (Either Name GlobalRdrElt))
    
    6342 6342
     
    
    6343 6343
     data UninferrableTyVarCtx
    
    6344 6344
       = UninfTyCtx_ClassContext [TcType]
    

  • compiler/GHC/Tc/Gen/Export.hs
    ... ... @@ -540,7 +540,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
    540 540
                    let avail = availFromGRE gre
    
    541 541
                        name = greName gre
    
    542 542
     
    
    543
    -               checkThLocalNameNoLift (ieLWrappedUserRdrName l name)
    
    543
    +               checkThLocalNameNoLift $ ieLWrappedUserRdrName l $ Right $! gre
    
    544 544
                    occs' <- check_occs occs ie [gre]
    
    545 545
                    (export_warn_spans', dont_warn_export', warn_txt_rn)
    
    546 546
                      <- process_warning export_warn_spans
    
    ... ... @@ -589,7 +589,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
    589 589
                         occs' <- check_occs occs ie [gre]
    
    590 590
                         return (Just avail, occs', exp_dflts)
    
    591 591
     
    
    592
    -               checkThLocalNameNoLift (ieLWrappedUserRdrName l name)
    
    592
    +               checkThLocalNameNoLift (ieLWrappedUserRdrName l $ Right $! gre)
    
    593 593
                    (export_warn_spans', dont_warn_export', warn_txt_rn)
    
    594 594
                      <- process_warning export_warn_spans
    
    595 595
                                         dont_warn_export
    
    ... ... @@ -617,7 +617,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
    617 617
                        all_gres = par : all_kids
    
    618 618
                        all_names = map greName all_gres
    
    619 619
     
    
    620
    -               checkThLocalNameNoLift (ieLWrappedUserRdrName l name)
    
    620
    +               checkThLocalNameNoLift (ieLWrappedUserRdrName l $ Right $! par)
    
    621 621
                    occs' <- check_occs occs ie all_gres
    
    622 622
                    (export_warn_spans', dont_warn_export', warn_txt_rn)
    
    623 623
                      <- process_warning export_warn_spans
    
    ... ... @@ -656,7 +656,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
    656 656
                        all_gres = par : all_kids
    
    657 657
                        all_names = map greName all_gres
    
    658 658
     
    
    659
    -               checkThLocalNameNoLift (ieLWrappedUserRdrName l name)
    
    659
    +               checkThLocalNameNoLift (ieLWrappedUserRdrName l $ Right $! par)
    
    660 660
                    occs' <- check_occs occs ie all_gres
    
    661 661
                    (export_warn_spans', dont_warn_export', warn_txt_rn)
    
    662 662
                      <- process_warning export_warn_spans
    
    ... ... @@ -794,8 +794,8 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
    794 794
           = addUsedGREs ExportDeprecationWarnings (pickGREs parent_rdr kid_gres)
    
    795 795
     
    
    796 796
     
    
    797
    -ieLWrappedUserRdrName :: LIEWrappedName GhcPs -> Name -> LIdOccP GhcRn
    
    798
    -ieLWrappedUserRdrName l n = fmap (\rdr -> WithUserRdr rdr n) $ ieLWrappedName l
    
    797
    +ieLWrappedUserRdrName :: LIEWrappedName GhcPs -> n -> GenLocated SrcSpanAnnN (WithUserRdr n)
    
    798
    +ieLWrappedUserRdrName l n = (\rdr -> WithUserRdr rdr n) <$> ieLWrappedName l
    
    799 799
     
    
    800 800
     -- | In what namespaces should we go looking for an import/export item
    
    801 801
     -- that is out of scope, for suggestions in error messages?
    
    ... ... @@ -901,7 +901,7 @@ lookupChildrenExport parent_gre child_gres rdr_items = mapAndReportM doOne rdr_i
    901 901
                      ; return (replaceLWrappedName n ub, gre)}
    
    902 902
                 FoundChild child@(GRE { gre_name = child_nm, gre_par = par }) ->
    
    903 903
                   do { checkPatSynParent spec_parent par child_nm
    
    904
    -                 ; checkThLocalNameNoLift (ieLWrappedUserRdrName n child_nm)
    
    904
    +                 ; checkThLocalNameNoLift (ieLWrappedUserRdrName n $ Right $! child)
    
    905 905
                      ; return (replaceLWrappedName n child_nm, child)
    
    906 906
                      }
    
    907 907
                 IncorrectParent p c gs -> failWithDcErr (parentGRE_name p) (greName c) gs
    

  • compiler/GHC/Tc/Utils/Env.hs
    ... ... @@ -252,15 +252,12 @@ tcLookupGlobal name
    252 252
               env <- getGblEnv
    
    253 253
             ; case lookupNameEnv (tcg_type_env env) name of {
    
    254 254
                     Just thing -> return thing ;
    
    255
    -                Nothing    ->
    
    256
    -
    
    257 255
                     -- Should it have been in the local envt?
    
    258 256
                     -- (NB: use semantic mod here, since names never use
    
    259 257
                     -- identity module, see Note [Identity versus semantic module].)
    
    260
    -          if nameIsLocalOrFrom (tcg_semantic_mod env) name
    
    261
    -          then notFound name  -- Internal names can happen in GHCi
    
    262
    -          else
    
    263
    -
    
    258
    +                Nothing | nameIsLocalOrFrom (tcg_semantic_mod env) name ->
    
    259
    +                              notFound (Left name)  -- Internal names can happen in GHCi
    
    260
    +                        | otherwise ->
    
    264 261
                -- Try home package table and external package table
    
    265 262
         do  { mb_thing <- tcLookupImported_maybe name
    
    266 263
             ; case mb_thing of
    
    ... ... @@ -1221,10 +1218,10 @@ pprBinders :: [Name] -> SDoc
    1221 1218
     pprBinders [bndr] = quotes (ppr bndr)
    
    1222 1219
     pprBinders bndrs  = pprWithCommas ppr bndrs
    
    1223 1220
     
    
    1224
    -notFound :: Name -> TcM TyThing
    
    1225
    -notFound name
    
    1221
    +notFound :: MayGRE GREInfo -> TcM TyThing
    
    1222
    +notFound mgre
    
    1226 1223
       = do { lcl_env <- getLclEnv
    
    1227
    -       ; lvls <- getCurrentAndBindLevel name
    
    1224
    +       ; lvls <- getCurrentAndBindLevel mgre
    
    1228 1225
            ; if    -- See Note [Out of scope might be a staging error]
    
    1229 1226
                | isUnboundName name -> failM  -- If the name really isn't in scope
    
    1230 1227
                                               -- don't report it again (#11941)
    
    ... ... @@ -1235,7 +1232,13 @@ notFound name
    1235 1232
                                               -- function, we check this completely independently
    
    1236 1233
                                               -- before scrutinizing lvls
    
    1237 1234
                | Just (_top_lvl_flag, bind_lvls, lvl@Splice {}) <- lvls
    
    1238
    -               -> failWithTc (TcRnBadlyLevelled (LevelCheckSplice name Nothing) bind_lvls (thLevelIndex lvl) Nothing ErrorWithoutFlag)
    
    1235
    +           , let name = mgreName mgre -> failWithTc $
    
    1236
    +             TcRnBadlyLevelled
    
    1237
    +               (LevelCheckSplice (mgre <$ noUserRdr name))
    
    1238
    +               bind_lvls
    
    1239
    +               (thLevelIndex lvl)
    
    1240
    +               Nothing
    
    1241
    +               ErrorWithoutFlag
    
    1239 1242
                | otherwise  -> pure ()
    
    1240 1243
     
    
    1241 1244
            ; if isTermVarOrFieldNameSpace (nameNameSpace name)
    
    ... ... @@ -1260,6 +1263,7 @@ notFound name
    1260 1263
                       -- so let's just not print it!  Getting a loop here is
    
    1261 1264
                       -- very unhelpful, because it hides one compiler bug with another
    
    1262 1265
            }
    
    1266
    +       where name = mgreName mgre
    
    1263 1267
     
    
    1264 1268
     wrongThingErr :: WrongThingSort -> TcTyThing -> Name -> TcM a
    
    1265 1269
     wrongThingErr expected thing name =
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -127,7 +127,7 @@ module GHC.Tc.Utils.Monad(
    127 127
       -- * Template Haskell context
    
    128 128
       recordThUse, recordThNeededRuntimeDeps,
    
    129 129
       keepAlive, getThLevel, getCurrentAndBindLevel, setThLevel,
    
    130
    -  addModFinalizersWithLclEnv,
    
    130
    +  addModFinalizersWithLclEnv, MayGRE, mgreName, mgreGRE,
    
    131 131
     
    
    132 132
       -- * Safe Haskell context
    
    133 133
       recordUnsafeInfer, finalSafeMode, fixSafeInstances,
    
    ... ... @@ -2468,32 +2468,40 @@ keepAlive name
    2468 2468
     getThLevel :: TcM ThLevel
    
    2469 2469
     getThLevel = do { env <- getLclEnv; return (getLclEnvThLevel env) }
    
    2470 2470
     
    
    2471
    -getCurrentAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, Set.Set ThLevelIndex, ThLevel))
    
    2472
    -getCurrentAndBindLevel name
    
    2471
    +getCurrentAndBindLevel :: MayGRE w -> TcRn (Maybe (TopLevelFlag, Set.Set ThLevelIndex, ThLevel))
    
    2472
    +getCurrentAndBindLevel mgre
    
    2473 2473
       = do { env <- getLclEnv;
    
    2474
    -       ; case lookupNameEnv (getLclEnvThBndrs env) name of
    
    2474
    +       ; case lookupNameEnv (getLclEnvThBndrs env) $ mgreName mgre  of
    
    2475 2475
                Nothing                  -> do
    
    2476
    -              lvls <- getExternalBindLvl name
    
    2477
    -              if Set.empty == lvls
    
    2478
    -                -- This case happens when code is generated for identifiers which are not
    
    2479
    -                -- in scope.
    
    2480
    -                --
    
    2481
    -                -- TODO: What happens if someone generates [|| GHC.Magic.dataToTag# ||]
    
    2482
    -                then do
    
    2483
    -                  return Nothing
    
    2484
    -                else return (Just (TopLevel, lvls, getLclEnvThLevel env))
    
    2476
    +              lvls <- getExternalBindLvl mgre
    
    2477
    +              let res
    
    2478
    +                    | Set.null lvls = Nothing
    
    2479
    +                      -- This case happens when code is generated for identifiers which are not
    
    2480
    +                      -- in scope.
    
    2481
    +                      --
    
    2482
    +                      -- TODO: What happens if someone generates [|| GHC.Magic.dataToTag# ||]
    
    2483
    +
    
    2484
    +                    | otherwise = Just (TopLevel, lvls, getLclEnvThLevel env)
    
    2485
    +              return res
    
    2485 2486
                Just (top_lvl, bind_lvl) -> return (Just (top_lvl, Set.singleton bind_lvl, getLclEnvThLevel env)) }
    
    2486 2487
     
    
    2487
    -getExternalBindLvl :: Name -> TcRn (Set.Set ThLevelIndex)
    
    2488
    -getExternalBindLvl name = do
    
    2489
    -  env <- getGlobalRdrEnv
    
    2488
    +getExternalBindLvl :: MayGRE w -> TcRn (Set.Set ThLevelIndex)
    
    2489
    +getExternalBindLvl mgre = do
    
    2490 2490
       mod <- getModule
    
    2491
    -  case lookupGRE_Name env name of
    
    2492
    -    Just gre -> return $ (Set.map thLevelIndexFromImportLevel (greLevels gre))
    
    2493
    -    Nothing ->
    
    2494
    -      if nameIsLocalOrFrom mod name
    
    2495
    -        then return $ Set.singleton topLevelIndex
    
    2496
    -        else return Set.empty
    
    2491
    +  return $ case mgre of
    
    2492
    +    Right gre -> Set.map thLevelIndexFromImportLevel (greLevels gre)
    
    2493
    +    Left name
    
    2494
    +      | nameIsLocalOrFrom mod name -> Set.singleton topLevelIndex
    
    2495
    +      | otherwise -> Set.empty
    
    2496
    +
    
    2497
    +-- | @'GlobalRdrEltX' w@ if we have on, 'Name' otherwise
    
    2498
    +type MayGRE w = Either Name (GlobalRdrEltX w)
    
    2499
    +
    
    2500
    +mgreName :: MayGRE w -> Name
    
    2501
    +mgreName = either id greName
    
    2502
    +
    
    2503
    +mgreGRE :: MayGRE w -> Maybe (GlobalRdrEltX w)
    
    2504
    +mgreGRE = either (const Nothing) Just
    
    2497 2505
     
    
    2498 2506
     setThLevel :: ThLevel -> TcM a -> TcRn a
    
    2499 2507
     setThLevel l = updLclEnv (setLclEnvThLevel l)
    

  • compiler/GHC/Types/Name/Reader.hs
    ... ... @@ -40,7 +40,7 @@ module GHC.Types.Name.Reader (
    40 40
             isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName,
    
    41 41
     
    
    42 42
             -- ** Preserving user-written qualification
    
    43
    -        WithUserRdr(..), noUserRdr, unLocWithUserRdr, userRdrName,
    
    43
    +        WithUserRdr(..), noUserRdr, unLocWithUserRdr, userRdrName, unwrapUserRdr,
    
    44 44
     
    
    45 45
             -- * Local mapping of 'RdrName' to 'Name.Name'
    
    46 46
             LocalRdrEnv, emptyLocalRdrEnv, extendLocalRdrEnv, extendLocalRdrEnvList,
    
    ... ... @@ -2247,9 +2247,12 @@ unLocWithUserRdr (L _ (WithUserRdr _ a)) = a
    2247 2247
     noUserRdr :: Name -> WithUserRdr Name
    
    2248 2248
     noUserRdr n = WithUserRdr (nameRdrName n) n
    
    2249 2249
     
    
    2250
    -userRdrName :: WithUserRdr Name -> RdrName
    
    2250
    +userRdrName :: WithUserRdr a -> RdrName
    
    2251 2251
     userRdrName (WithUserRdr rdr _) = rdr
    
    2252 2252
     
    
    2253
    +unwrapUserRdr :: WithUserRdr a -> a
    
    2254
    +unwrapUserRdr (WithUserRdr _ a) = a
    
    2255
    +
    
    2253 2256
     rdrQual_maybe :: RdrName -> Maybe ModuleName
    
    2254 2257
     rdrQual_maybe = \case
    
    2255 2258
       Qual q _ -> Just q
    

  • testsuite/tests/splice-imports/SI03.stderr
    1 1
     SI03.hs:10:11: error: [GHC-28914]
    
    2 2
         • Level error: ‘sid’ is bound at level 0 but used at level -1
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘SI01A’ at SI03.hs:5:1-12
    
    3
    +    • imported from ‘SI01A’ at SI03.hs:5:1-12
    
    5 4
         • In the untyped splice: $(sid [| pure () |])
    
    6 5
     

  • testsuite/tests/splice-imports/SI05.stderr
    1 1
     SI05.hs:10:11: error: [GHC-28914]
    
    2
    -    • Level error: ‘SI01A.sid’ is bound at level 0 but used at level -1
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘SI01A’ at SI05.hs:6:1-12
    
    2
    +    • Level error: ‘sid’ is bound at level 0 but used at level -1
    
    3
    +    • imported from ‘SI01A’ at SI05.hs:6:1-12
    
    5 4
         • In the untyped splice: $(sid [| pure () |])
    
    6 5
     
    
    7 6
     SI05.hs:10:11: error: [GHC-87543]
    

  • testsuite/tests/splice-imports/SI25.stderr
    1 1
     SI25.hs:16:13: error: [GHC-28914]
    
    2 2
         • Level error: ‘nestedCode’ is bound at level -1
    
    3 3
           but used at level -2
    
    4
    -    • Available from the imports:
    
    5
    -      • imported from ‘SI25Helper’ at -1 at SI25.hs:6:1-24
    
    4
    +    • imported from ‘SI25Helper’ at -1 at SI25.hs:6:1-24
    
    6 5
         • In the untyped splice: $(nestedCode "nested")
    
    7 6
           In the untyped splice: $($(nestedCode "nested"))
    
    8 7
     

  • testsuite/tests/splice-imports/SI28.stderr
    1 1
     SI28.hs:8:13: error: [GHC-28914]
    
    2 2
         • Level error: ‘id’ is bound at level 1 but used at level 0
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘Prelude’ at 1 at SI28.hs:6:1-20
    
    3
    +    • imported from ‘Prelude’ at 1 at SI28.hs:6:1-20
    
    5 4
         • In the Template Haskell quotation: [| id |]
    
    6 5
           In the untyped splice: $([| id |])
    
    7 6
     

  • testsuite/tests/splice-imports/SI31.stderr
    1 1
     <interactive>:2:3: error: [GHC-28914]
    
    2 2
         • Level error: ‘id’ is bound at level 0 but used at level -1
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘Prelude’
    
    3
    +    • imported from ‘Prelude’
    
    5 4
         • In the untyped splice: $(id [| () |])
    
    6 5
     

  • testsuite/tests/splice-imports/T26088.stderr
    1 1
     T26088A.hs:8:8: error: [GHC-28914]
    
    2 2
         • Level error: ‘a’ is bound at level -1 but used at level 1
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘T26088B’ at -1 at T26088A.hs:4:1-21
    
    3
    +    • imported from ‘T26088B’ at -1 at T26088A.hs:4:1-21
    
    5 4
         • In the Template Haskell quotation: [| a |]
    
    6 5
     

  • testsuite/tests/splice-imports/T26090.stderr
    1 1
     T26090.hs:2:17: error: [GHC-28914]
    
    2 2
         • Level error: ‘a’ is bound at level 1 but used at level 0
    
    3
    -    • Available from the imports:
    
    4
    -      • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    3
    +    • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    5 4
     
    
    6 5
     T26090.hs:4:17: error: [GHC-28914]
    
    7 6
         • Level error: ‘s’ is bound at level 1 but used at level 0
    
    8
    -    • Available from the imports:
    
    9
    -      • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    7
    +    • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    10 8
         • In the export: S(s)
    
    11 9
     
    
    12 10
     T26090.hs:5:17: error: [GHC-28914]
    
    13 11
         • Level error: ‘R’ is bound at level 1 but used at level 0
    
    14
    -    • Available from the imports:
    
    15
    -      • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    12
    +    • imported from ‘T26090A’ at 1 at T26090.hs:8:1-20
    
    16 13
     

  • testsuite/tests/splice-imports/T26616.hs
    1
    +{-# LANGUAGE ExplicitLevelImports, NoImplicitPrelude #-}
    
    2
    +module T26616 where
    
    3
    +
    
    4
    +import quote  Data.Maybe qualified as Q
    
    5
    +import        Data.Maybe qualified as Z
    
    6
    +import splice Data.Maybe qualified as S
    
    7
    +
    
    8
    +foo = Q.isJust

  • testsuite/tests/splice-imports/T26616.stderr
    1
    +T26616.hs:8:7: error: [GHC-28914]
    
    2
    +    • Level error: ‘Q.isJust’ is bound at level 1 but used at level 0
    
    3
    +    • imported qualified from ‘Data.Maybe’ at 1 at T26616.hs:4:1-39
    
    4
    +

  • testsuite/tests/splice-imports/all.T
    ... ... @@ -52,3 +52,4 @@ test('T26090', [], multimod_compile_fail, ['T26090', '-v0'])
    52 52
     test('ModuleExport', [], multimod_compile_fail, ['ModuleExport', '-v0'])
    
    53 53
     test('LevelImportExports', [], makefile_test, [])
    
    54 54
     test('DodgyLevelExport', [], multimod_compile, ['DodgyLevelExport', '-v0 -Wdodgy-exports'])
    
    55
    +test('T26616', normal,  compile_fail, [''])