[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Remove the dependency on the ghc-linters stage

Marge Bot gitlab at gitlab.haskell.org
Mon Oct 12 14:11:12 UTC 2020



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
274e21f0 by Hécate at 2020-10-11T10:55:56+02:00
Remove the dependency on the ghc-linters stage

- - - - -
990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00
Fall back to types when looking up data constructors (#18740)

Before this patch, referring to a data constructor in a term-level
context led to a scoping error:

    ghci> id Int
    <interactive>:1:4: error: Data constructor not in scope: Int

After this patch, the renamer falls back to the type namespace
and successfully finds the Int. It is then rejected in the type
checker with a more useful error message:

    <interactive>:1:4: error:
    • Illegal term-level use of the type constructor ‘Int’
        imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
    • In the first argument of ‘id’, namely ‘Int’
      In the expression: id Int

We also do this for type variables.

- - - - -
431aea3e by Sylvain Henry at 2020-10-12T10:11:02-04:00
DynFlags: refactor DmdAnal

Make demand analysis usable without having to provide DynFlags.

- - - - -


22 changed files:

- .gitlab-ci.yml
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Types/Name/Occurrence.hs
- compiler/GHC/Types/Name/Reader.hs
- testsuite/tests/module/mod132.stderr
- testsuite/tests/module/mod147.stderr
- testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr
- + testsuite/tests/rename/should_fail/T18740a.hs
- + testsuite/tests/rename/should_fail/T18740a.stderr
- + testsuite/tests/rename/should_fail/T18740b.hs
- + testsuite/tests/rename/should_fail/T18740b.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/th/T14627.stderr
- + testsuite/tests/th/T18740c.hs
- + testsuite/tests/th/T18740c.stderr
- + testsuite/tests/th/T18740d.hs
- + testsuite/tests/th/T18740d.stderr
- testsuite/tests/th/all.T


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian:
 
 hadrian-ghc-in-ghci:
   stage: quick-build
-  needs: [ghc-linters, lint-linters, lint-submods]
+  needs: [lint-linters, lint-submods]
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   before_script:
     # workaround for docker permissions
@@ -282,7 +282,7 @@ hadrian-ghc-in-ghci:
 
 .lint-params:
   stage: lint
-  needs: [ghc-linters, lint-submods]
+  needs: [lint-submods]
   tags:
     - lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"


=====================================
compiler/GHC/Core/Opt/DmdAnal.hs
=====================================
@@ -9,18 +9,20 @@
 
 {-# LANGUAGE CPP #-}
 
-module GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) where
+module GHC.Core.Opt.DmdAnal
+   ( DmdAnalOpts(..)
+   , dmdAnalProgram
+   )
+where
 
 #include "HsVersions.h"
 
 import GHC.Prelude
 
-import GHC.Driver.Session
 import GHC.Core.Opt.WorkWrap.Utils
 import GHC.Types.Demand   -- All of it
 import GHC.Core
 import GHC.Core.Multiplicity ( scaledThing )
-import GHC.Core.Seq     ( seqBinds )
 import GHC.Utils.Outputable
 import GHC.Types.Var.Env
 import GHC.Types.Var.Set
@@ -29,7 +31,6 @@ import Data.List        ( mapAccumL )
 import GHC.Core.DataCon
 import GHC.Types.ForeignCall ( isSafeForeignCall )
 import GHC.Types.Id
-import GHC.Types.Id.Info
 import GHC.Core.Utils
 import GHC.Core.TyCon
 import GHC.Core.Type
@@ -41,7 +42,6 @@ import GHC.Utils.Panic
 import GHC.Data.Maybe         ( isJust )
 import GHC.Builtin.PrimOps
 import GHC.Builtin.Types.Prim ( realWorldStatePrimTy )
-import GHC.Utils.Error        ( dumpIfSet_dyn, DumpFormat (..) )
 import GHC.Types.Unique.Set
 
 {-
@@ -52,14 +52,21 @@ import GHC.Types.Unique.Set
 ************************************************************************
 -}
 
-dmdAnalProgram :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram
-dmdAnalProgram dflags fam_envs binds = do
-  let env             = emptyAnalEnv dflags fam_envs
-  let binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds
-  dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $
-    dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds
-  -- See Note [Stamp out space leaks in demand analysis]
-  seqBinds binds_plus_dmds `seq` return binds_plus_dmds
+-- | Options for the demand analysis
+data DmdAnalOpts = DmdAnalOpts
+   { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries
+   }
+
+-- | Outputs a new copy of the Core program in which binders have been annotated
+-- with demand and strictness information.
+--
+-- Note: use `seqBinds` on the result to avoid leaks due to lazyness (cf Note
+-- [Stamp out space leaks in demand analysis])
+dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> CoreProgram -> CoreProgram
+dmdAnalProgram opts fam_envs binds = binds_plus_dmds
+   where
+      env             = emptyAnalEnv opts fam_envs
+      binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds
 
 -- Analyse a (group of) top-level binding(s)
 dmdAnalTopBind :: AnalEnv
@@ -1235,31 +1242,13 @@ type DFunFlag = Bool  -- indicates if the lambda being considered is in the
 notArgOfDfun :: DFunFlag
 notArgOfDfun = False
 
-{-  Note [dmdAnalEnv performance]
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-It's tempting to think that removing the dynflags from AnalEnv would improve
-performance. After all when analysing recursive groups we end up allocating
-a lot of environments. However this is not the case.
-
-We do get some performance by making AnalEnv smaller. However very often we
-defer computation which means we have to capture the dynflags in the thunks
-we allocate. Doing this naively in practice causes more allocation than the
-removal of DynFlags saves us.
-
-In theory it should be possible to make this better if we are stricter in
-the analysis and therefore allocate fewer thunks. But I couldn't get there
-in a few hours and overall the impact on GHC here is small, and there are
-bigger fish to fry. So for new the env will keep a reference to the flags.
--}
-
-data AnalEnv
-  = AE { ae_dflags :: DynFlags -- See Note [dmdAnalEnv performance]
-       , ae_sigs   :: SigEnv
-       , ae_virgin :: Bool    -- True on first iteration only
+data AnalEnv = AE
+   { ae_strict_dicts :: !Bool -- ^ Enable strict dict
+   , ae_sigs         :: !SigEnv
+   , ae_virgin       :: !Bool -- ^ True on first iteration only
                               -- See Note [Initialising strictness]
-       , ae_fam_envs :: FamInstEnvs
- }
+   , ae_fam_envs     :: !FamInstEnvs
+   }
 
         -- We use the se_env to tell us whether to
         -- record info about a variable in the DmdEnv
@@ -1271,17 +1260,18 @@ data AnalEnv
 type SigEnv = VarEnv (StrictSig, TopLevelFlag)
 
 instance Outputable AnalEnv where
-  ppr (AE { ae_sigs = env, ae_virgin = virgin })
-    = text "AE" <+> braces (vcat
-         [ text "ae_virgin =" <+> ppr virgin
-         , text "ae_sigs =" <+> ppr env ])
-
-emptyAnalEnv :: DynFlags -> FamInstEnvs -> AnalEnv
-emptyAnalEnv dflags fam_envs
-    = AE { ae_dflags = dflags
-         , ae_sigs = emptySigEnv
-         , ae_virgin = True
-         , ae_fam_envs = fam_envs
+  ppr env = text "AE" <+> braces (vcat
+         [ text "ae_virgin =" <+> ppr (ae_virgin env)
+         , text "ae_strict_dicts =" <+> ppr (ae_strict_dicts env)
+         , text "ae_sigs =" <+> ppr (ae_sigs env)
+         ])
+
+emptyAnalEnv :: DmdAnalOpts -> FamInstEnvs -> AnalEnv
+emptyAnalEnv opts fam_envs
+    = AE { ae_strict_dicts = dmd_strict_dicts opts
+         , ae_sigs         = emptySigEnv
+         , ae_virgin       = True
+         , ae_fam_envs     = fam_envs
          }
 
 emptySigEnv :: SigEnv
@@ -1334,7 +1324,7 @@ findBndrDmd env arg_of_dfun dmd_ty id
     id_ty = idType id
 
     strictify dmd
-      | gopt Opt_DictsStrict (ae_dflags env)
+      | ae_strict_dicts env
              -- We never want to strictify a recursive let. At the moment
              -- annotateBndr is only call for non-recursive lets; if that
              -- changes, we need a RecFlag parameter and another guard here.


=====================================
compiler/GHC/Core/Opt/Pipeline.hs
=====================================
@@ -24,7 +24,7 @@ import GHC.Core.Ppr     ( pprCoreBindings, pprCoreExpr )
 import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr )
 import GHC.Types.Id.Info
 import GHC.Core.Stats   ( coreBindsSize, coreBindsStats, exprSize )
-import GHC.Core.Utils   ( mkTicks, stripTicksTop )
+import GHC.Core.Utils   ( mkTicks, stripTicksTop, dumpIdInfoOfProgram )
 import GHC.Core.Lint    ( endPass, lintPassResult, dumpPassResult,
                           lintAnnots )
 import GHC.Core.Opt.Simplify       ( simplTopBinds, simplExpr, simplRules )
@@ -41,15 +41,17 @@ import GHC.Utils.Error  ( withTiming, withTimingD, DumpFormat (..) )
 import GHC.Types.Basic
 import GHC.Types.Var.Set
 import GHC.Types.Var.Env
+import GHC.Types.Demand
 import GHC.Core.Opt.LiberateCase ( liberateCase )
 import GHC.Core.Opt.StaticArgs   ( doStaticArgs )
 import GHC.Core.Opt.Specialise   ( specProgram)
 import GHC.Core.Opt.SpecConstr   ( specConstrProgram)
-import GHC.Core.Opt.DmdAnal      ( dmdAnalProgram )
+import GHC.Core.Opt.DmdAnal
 import GHC.Core.Opt.CprAnal      ( cprAnalProgram )
 import GHC.Core.Opt.CallArity    ( callArityAnalProgram )
 import GHC.Core.Opt.Exitify      ( exitifyProgram )
 import GHC.Core.Opt.WorkWrap     ( wwTopBinds )
+import GHC.Core.Seq (seqBinds)
 import GHC.Types.SrcLoc
 import GHC.Utils.Misc
 import GHC.Unit.Module.Env
@@ -484,7 +486,7 @@ doCorePass CoreDoExitify             = {-# SCC "Exitify" #-}
                                        doPass exitifyProgram
 
 doCorePass CoreDoDemand              = {-# SCC "DmdAnal" #-}
-                                       doPassDFM dmdAnalProgram
+                                       doPassDFM dmdAnal
 
 doCorePass CoreDoCpr                 = {-# SCC "CprAnal" #-}
                                        doPassDFM cprAnalProgram
@@ -1074,3 +1076,16 @@ transferIdInfo exported_id local_id
                                (ruleInfo local_info)
         -- Remember to set the function-name field of the
         -- rules as we transfer them from one function to another
+
+
+
+dmdAnal :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram
+dmdAnal dflags fam_envs binds = do
+  let opts = DmdAnalOpts
+               { dmd_strict_dicts = gopt Opt_DictsStrict dflags
+               }
+      binds_plus_dmds = dmdAnalProgram opts fam_envs binds
+  Err.dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $
+    dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds
+  -- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal
+  seqBinds binds_plus_dmds `seq` return binds_plus_dmds


=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -2247,8 +2247,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t]
 
 --------------- Expressions -----------------
 repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp))
-repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str
-                   | otherwise                  = repVar str
+repVarOrCon vc str
+    | isVarNameSpace ns = repVar str  -- Both type and term variables (#18740)
+    | otherwise         = repCon str
+  where
+    ns = nameNameSpace vc
 
 repVar :: Core TH.Name -> MetaM (Core (M TH.Exp))
 repVar (MkC s) = rep2 varEName [s]


=====================================
compiler/GHC/Rename/Env.hs
=====================================
@@ -1,5 +1,6 @@
 {-# LANGUAGE CPP            #-}
 {-# LANGUAGE NamedFieldPuns #-}
+{-# LANGUAGE TypeApplications #-}
 
 {-
 (c) The GRASP/AQUA Project, Glasgow University, 1992-2006
@@ -1006,6 +1007,17 @@ lookup_demoted rdr_name
            , text "instead of"
            , quotes (ppr name) <> dot ]
 
+-- If the given RdrName can be promoted to the type level and its promoted variant is in scope,
+-- lookup_promoted returns the corresponding type-level Name.
+-- Otherwise, the function returns Nothing.
+-- See Note [Promotion] below.
+lookup_promoted :: RdrName -> RnM (Maybe Name)
+lookup_promoted rdr_name
+  | Just promoted_rdr <- promoteRdrName rdr_name
+  = lookupOccRn_maybe promoted_rdr
+  | otherwise
+  = return Nothing
+
 badVarInType :: RdrName -> RnM Name
 badVarInType rdr_name
   = do { addErr (text "Illegal promoted term variable in a type:"
@@ -1041,6 +1053,26 @@ its namespace to DataName and do a second lookup.
 
 The final result (after the renamer) will be:
   HsTyVar ("Zero", DataName)
+
+Note [Promotion]
+~~~~~~~~~~~~~~~
+When the user mentions a type constructor or a type variable in a
+term-level context, then we report that a value identifier was expected
+instead of a type-level one. That makes error messages more precise.
+Previously, such errors contained only the info that a given value was out of scope (#18740).
+We promote the namespace of RdrName and look up after that
+(see the functions promotedRdrName and lookup_promoted).
+
+In particular, we have the following error message
+  • Illegal term-level use of the type constructor ‘Int’
+      imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
+  • In the first argument of ‘id’, namely ‘Int’
+    In the expression: id Int
+    In an equation for ‘x’: x = id Int
+
+when the user writes the following declaration
+
+  x = id Int
 -}
 
 lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName
@@ -1055,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id
 
 lookupOccRn_overloaded :: Bool -> RdrName
                        -> RnM (Maybe (Either Name [Name]))
-lookupOccRn_overloaded overload_ok
-  = lookupOccRnX_maybe global_lookup Left
-      where
-        global_lookup :: RdrName -> RnM (Maybe (Either Name [Name]))
-        global_lookup n =
-          runMaybeT . msum . map MaybeT $
-            [ lookupGlobalOccRn_overloaded overload_ok n
-            , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ]
+lookupOccRn_overloaded overload_ok rdr_name
+  = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name
+       ; case mb_name of
+           Nothing   -> fmap @Maybe Left <$> lookup_promoted rdr_name
+                        -- See Note [Promotion].
+                        -- We try looking up the name as a
+                        -- type constructor or type variable, if
+                        -- we failed to look up the name at the term level.
+           p         -> return p }
+
+  where
+    global_lookup :: RdrName -> RnM (Maybe (Either Name [Name]))
+    global_lookup n =
+      runMaybeT . msum . map MaybeT $
+        [ lookupGlobalOccRn_overloaded overload_ok n
+        , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ]
 
 
 


=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -755,6 +755,7 @@ tc_infer_assert assert_name
 tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType)
 tc_infer_id id_name
  = do { thing <- tcLookup id_name
+      ; global_env <- getGlobalRdrEnv
       ; case thing of
              ATcId { tct_id = id }
                -> do { check_local_id occ id
@@ -772,9 +773,31 @@ tc_infer_id id_name
                    | otherwise
                    -> nonBidirectionalErr id_name
 
+             AGlobal (ATyCon ty_con)
+               -> fail_tycon global_env ty_con
+
+             ATyVar name _
+                -> failWithTc $
+                     text "Illegal term-level use of the type variable"
+                       <+> quotes (ppr name)
+                       $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name))
+
+             ATcTyCon ty_con
+               -> fail_tycon global_env ty_con
+
              _ -> failWithTc $
                   ppr thing <+> text "used where a value identifier was expected" }
   where
+    fail_tycon global_env ty_con =
+      let pprov = case lookupGRE_Name global_env (tyConName ty_con) of
+            Just gre -> nest 2 (pprNameProvenance gre)
+            Nothing  -> empty
+      in failWithTc (term_level_tycons ty_con $$ pprov)
+
+    term_level_tycons ty_con
+      = text "Illegal term-level use of the type constructor"
+          <+> quotes (ppr (tyConName ty_con))
+
     occ = nameOccName id_name
 
     return_id id = return (HsVar noExtField (noLoc id), idType id)
@@ -1144,4 +1167,3 @@ addExprCtxt e thing_inside
 
 exprCtxt :: HsExpr GhcRn -> SDoc
 exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr))
-


=====================================
compiler/GHC/Types/Name/Occurrence.hs
=====================================
@@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence (
         mkDFunOcc,
         setOccNameSpace,
         demoteOccName,
+        promoteOccName,
         HasOccName(..),
 
         -- ** Derived 'OccName's
@@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc"
 
 -- demoteNameSpace lowers the NameSpace if possible.  We can not know
 -- in advance, since a TvName can appear in an HsTyVar.
--- See Note [Demotion] in GHC.Rename.Env
+-- See Note [Demotion] in GHC.Rename.Env.
 demoteNameSpace :: NameSpace -> Maybe NameSpace
 demoteNameSpace VarName = Nothing
 demoteNameSpace DataName = Nothing
 demoteNameSpace TvName = Nothing
 demoteNameSpace TcClsName = Just DataName
 
+-- promoteNameSpace promotes the NameSpace as follows.
+-- See Note [Promotion] in GHC.Rename.Env.
+promoteNameSpace :: NameSpace -> Maybe NameSpace
+promoteNameSpace DataName = Just TcClsName
+promoteNameSpace VarName = Just TvName
+promoteNameSpace TcClsName = Nothing
+promoteNameSpace TvName = Nothing
+
 {-
 ************************************************************************
 *                                                                      *
@@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName
 mkClsOccFS = mkOccNameFS clsName
 
 -- demoteOccName lowers the Namespace of OccName.
--- see Note [Demotion]
+-- See Note [Demotion] in GHC.Rename.Env.
 demoteOccName :: OccName -> Maybe OccName
 demoteOccName (OccName space name) = do
   space' <- demoteNameSpace space
   return $ OccName space' name
 
+-- promoteOccName promotes the NameSpace of OccName.
+-- See Note [Promotion] in GHC.Rename.Env.
+promoteOccName :: OccName -> Maybe OccName
+promoteOccName (OccName space name) = do
+  space' <- promoteNameSpace space
+  return $ OccName space' name
+
 -- Name spaces are related if there is a chance to mean the one when one writes
 -- the other, i.e. variables <-> data constructors and type variables <-> type constructors
 nameSpacesRelated :: NameSpace -> NameSpace -> Bool


=====================================
compiler/GHC/Types/Name/Reader.hs
=====================================
@@ -32,7 +32,7 @@ module GHC.Types.Name.Reader (
         nameRdrName, getRdrName,
 
         -- ** Destruction
-        rdrNameOcc, rdrNameSpace, demoteRdrName,
+        rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName,
         isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual,
         isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName,
 
@@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace
 rdrNameSpace = occNameSpace . rdrNameOcc
 
 -- demoteRdrName lowers the NameSpace of RdrName.
--- see Note [Demotion] in GHC.Types.Name.Occurrence
+-- See Note [Demotion] in GHC.Rename.Env
 demoteRdrName :: RdrName -> Maybe RdrName
 demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ)
 demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ)
 demoteRdrName (Orig _ _) = Nothing
 demoteRdrName (Exact _) = Nothing
 
+-- promoteRdrName promotes the NameSpace of RdrName.
+-- See Note [Promotion] in GHC.Rename.Env.
+promoteRdrName :: RdrName -> Maybe RdrName
+promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ)
+promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ)
+promoteRdrName (Orig _ _) = Nothing
+promoteRdrName (Exact _)  = Nothing
+
         -- These two are the basic constructors
 mkRdrUnqual :: OccName -> RdrName
 mkRdrUnqual occ = Unqual occ


=====================================
testsuite/tests/module/mod132.stderr
=====================================
@@ -1,4 +1,7 @@
 
 mod132.hs:6:7: error:
-    • Data constructor not in scope: Foo
-    • Perhaps you meant variable ‘foo’ (line 6)
+     Illegal term-level use of the type constructor ‘Foo’
+        imported from ‘Mod132_B’ at mod132.hs:4:1-15
+        (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14)
+     In the expression: Foo
+      In an equation for ‘foo’: foo = Foo


=====================================
testsuite/tests/module/mod147.stderr
=====================================
@@ -1,2 +1,7 @@
 
-mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t
+mod147.hs:6:5:
+     Illegal term-level use of the type constructor ‘D’
+        imported from ‘Mod147_A’ at mod147.hs:4:1-15
+        (and originally defined at Mod147_A.hs:3:1-14)
+     In the expression: D 4
+      In an equation for ‘x’: x = D 4


=====================================
testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr
=====================================
@@ -1,3 +1,7 @@
 
-RnStaticPointersFail02.hs:5:12: error:
-    Data constructor not in scope: T
+RnStaticPointersFail02.hs:5:12:
+Illegal term-level use of the type constructor ‘T’
+  defined at RnStaticPointersFail02.hs:7:1
+In the body of a static form: T
+  In the expression: static T
+  In an equation for ‘f’: f = static T


=====================================
testsuite/tests/rename/should_fail/T18740a.hs
=====================================
@@ -0,0 +1,3 @@
+module T18740a where
+
+x = Int


=====================================
testsuite/tests/rename/should_fail/T18740a.stderr
=====================================
@@ -0,0 +1,7 @@
+
+T18740a.hs:3:5: error:
+    • Illegal term-level use of the type constructor ‘Int’
+        imported from ‘Prelude’ at T18740a.hs:1:8-14
+        (and originally defined in ‘GHC.Types’)
+    • In the expression: Int
+      In an equation for ‘x’: x = Int


=====================================
testsuite/tests/rename/should_fail/T18740b.hs
=====================================
@@ -0,0 +1,6 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module T18740b where
+
+import Data.Proxy
+
+f (Proxy :: Proxy a) = a


=====================================
testsuite/tests/rename/should_fail/T18740b.stderr
=====================================
@@ -0,0 +1,6 @@
+
+T18740b.hs:6:24: error:
+    • Illegal term-level use of the type variable ‘a’
+         bound at T18740b.hs:6:4
+    • In the expression: a
+      In an equation for ‘f’: f (Proxy :: Proxy a) = a


=====================================
testsuite/tests/rename/should_fail/all.T
=====================================
@@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, [''])
 test('T18145', normal, compile_fail, [''])
 test('T18240a', normal, compile_fail, [''])
 test('T18240b', normal, compile_fail, [''])
+test('T18740a', normal, compile_fail, [''])
+test('T18740b', normal, compile_fail, [''])


=====================================
testsuite/tests/th/T14627.stderr
=====================================
@@ -1,2 +1,7 @@
 
-T14627.hs:4:1: error: Data constructor not in scope: Bool
+T14627.hs:4:1:
+Illegal term-level use of the type constructor ‘Bool’
+  imported from ‘Prelude’ at T14627.hs:1:1
+  (and originally defined in ‘GHC.Types’)
+In the expression: Bool
+ In an equation for ‘f’: f = Bool


=====================================
testsuite/tests/th/T18740c.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
+module T18740c where
+
+import Data.Proxy
+import Language.Haskell.TH.Syntax
+
+[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return []


=====================================
testsuite/tests/th/T18740c.stderr
=====================================
@@ -0,0 +1,6 @@
+
+T18740c.hs:9:1: error:
+    • Illegal term-level use of the type variable ‘a’
+        bound at T18740c.hs:9:1
+    • In the expression: a
+      In an equation for ‘f’: f (Proxy :: Proxy a) = a


=====================================
testsuite/tests/th/T18740d.hs
=====================================
@@ -0,0 +1,17 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module T18740d where
+
+import Language.Haskell.TH
+
+-- If we used 'ConE' here, then we would expect this error message:
+--
+--   Illegal term-level use of the type constructor ‘Bool’
+--     imported from ‘Prelude’ at T18740d.hs:3:8-14
+--     (and originally defined in ‘GHC.Types’)
+--
+-- But we used 'VarE', so the error message should say:
+--
+--   Illegal variable name: ‘Bool’
+--
+e1 = $(return (VarE ''Bool))


=====================================
testsuite/tests/th/T18740d.stderr
=====================================
@@ -0,0 +1,5 @@
+
+T18740d.hs:17:7: error:
+    • Illegal variable name: ‘Bool’
+      When splicing a TH expression: GHC.Types.Bool
+    • In the untyped splice: $(return (VarE ''Bool))


=====================================
testsuite/tests/th/all.T
=====================================
@@ -515,3 +515,5 @@ test('T18121', normal, compile, [''])
 test('T18123', normal, compile, [''])
 test('T18388', normal, compile, [''])
 test('T18612', normal, compile, [''])
+test('T18740c', normal, compile_fail, [''])
+test('T18740d', normal, compile_fail, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f283f889f27a50c195feed0d62127d067ec1c8a8...431aea3ecec5acafcdd71f24a48562d9f13121b9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f283f889f27a50c195feed0d62127d067ec1c8a8...431aea3ecec5acafcdd71f24a48562d9f13121b9
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201012/af675912/attachment-0001.html>


More information about the ghc-commits mailing list