Cheng Shao deleted branch wip/ubsan-fixes at Glasgow Haskell Compiler / GHC
--
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/jacco/haddock/codeblock-highlighting] documentation
by Jacco Krijnen (@jacco) 17 Apr '25
by Jacco Krijnen (@jacco) 17 Apr '25
17 Apr '25
Jacco Krijnen pushed to branch wip/jacco/haddock/codeblock-highlighting at Glasgow Haskell Compiler / GHC
Commits:
008f91e4 by Jacco Krijnen at 2025-04-17T20:03:27+02:00
documentation
- - - - -
1 changed file:
- utils/haddock/doc/markup.rst
Changes:
=====================================
utils/haddock/doc/markup.rst
=====================================
@@ -845,24 +845,52 @@ Unicode (or ISO 10646). For example, the references ``λ``,
Code Blocks
~~~~~~~~~~~
-Displayed blocks of code are indicated by surrounding a paragraph with
-``@...@`` or by preceding each line of a paragraph with ``>`` (we often
-call these “bird tracks”). For example: ::
+Displayed blocks of code can be indicated in different ways:
- -- | This documentation includes two blocks of code:
+- by surrounding a paragraph with ``@...@``
+- by preceding each line of a paragraph with ``>`` (we often
+ call these “bird tracks”)
+- by surrounding a paragraph with triple backticks `` ``` `` (also known
+ as fenced code blocks) and optionally indicating a language. Haddock
+ will apply syntax highlighting when a language is provided.
+
+For example: ::
+
+ -- | This documentation includes four blocks of code:
--
-- @
-- f x = x + x
-- @
--
-- > g x = x * 42
-
-There is an important difference between the two forms of code block: in
-the bird-track form, the text to the right of the ‘\ ``>``\ ’ is
-interpreted literally, whereas the ``@...@`` form interprets markup as
-normal inside the code block. In particular, ``/`` is markup for italics,
-and so e.g. ``@x / y / z@`` renders as ``x`` followed by italic
-``y`` with no slashes, followed by ``z``.
+ --
+ -- ```
+ -- fix x = f (fix x)
+ -- ```
+ --
+ -- ```haskell
+ -- data Bool = False | True
+ -- ```
+
+
+There is an important difference between the forms of code block: bird
+tracks and fenced code blocks interpret text literally, whereas the
+``@...@`` form interprets haddock markup as normal inside the code
+block.
+
+For example, ``@x / y / z@`` renders as
+
++---------------------+-------------------------------+
+| Haddock | Rendered |
++=====================+===============================+
+| ``@x / y / z@`` | .. raw:: html |
+| | |
+| | <code>x <i>y</i> z</code> |
++---------------------+-------------------------------+
+| ``> x y z`` | .. raw:: html |
+| | |
+| | <code>x / y / z</code> |
++---------------------+-------------------------------+
Examples
~~~~~~~~
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/008f91e4d74c8cc36ab65084cbcc4db…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/008f91e4d74c8cc36ab65084cbcc4db…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/romes/more-debugger] Export sizeOccEnv from GHC.Types.Name.Occurrence
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
17 Apr '25
Rodrigo Mesquita pushed to branch wip/romes/more-debugger at Glasgow Haskell Compiler / GHC
Commits:
fd7f3f11 by Rodrigo Mesquita at 2025-04-17T17:57:43+01:00
Export sizeOccEnv from GHC.Types.Name.Occurrence
Counts the number of OccNames in an OccEnv
- - - - -
1 changed file:
- compiler/GHC/Types/Name/Occurrence.hs
Changes:
=====================================
compiler/GHC/Types/Name/Occurrence.hs
=====================================
@@ -92,6 +92,7 @@ module GHC.Types.Name.Occurrence (
plusOccEnv, plusOccEnv_C,
extendOccEnv_Acc, filterOccEnv, delListFromOccEnv, delFromOccEnv,
alterOccEnv, minusOccEnv, minusOccEnv_C, minusOccEnv_C_Ns,
+ sizeOccEnv,
pprOccEnv, forceOccEnv,
intersectOccEnv_C,
@@ -803,6 +804,10 @@ minusOccEnv_C_Ns f (MkOccEnv as) (MkOccEnv bs) =
then Nothing
else Just m
+sizeOccEnv :: OccEnv a -> Int
+sizeOccEnv (MkOccEnv as) =
+ nonDetFoldFsEnv (\ m !acc -> acc + sizeUFM m) 0 as
+
instance Outputable a => Outputable (OccEnv a) where
ppr x = pprOccEnv ppr x
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd7f3f11aa945f910a5f41ef50ea277…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd7f3f11aa945f910a5f41ef50ea277…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Simon Peyton Jones pushed new branch wip/T25440 at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T25440
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/romes/more-debugger] Export sizeOccEnv from GHC.Types.Name.Occurrence
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
17 Apr '25
Rodrigo Mesquita pushed to branch wip/romes/more-debugger at Glasgow Haskell Compiler / GHC
Commits:
c4dd98a9 by Rodrigo Mesquita at 2025-04-17T17:29:24+01:00
Export sizeOccEnv from GHC.Types.Name.Occurrence
- - - - -
1 changed file:
- compiler/GHC/Types/Name/Occurrence.hs
Changes:
=====================================
compiler/GHC/Types/Name/Occurrence.hs
=====================================
@@ -92,6 +92,7 @@ module GHC.Types.Name.Occurrence (
plusOccEnv, plusOccEnv_C,
extendOccEnv_Acc, filterOccEnv, delListFromOccEnv, delFromOccEnv,
alterOccEnv, minusOccEnv, minusOccEnv_C, minusOccEnv_C_Ns,
+ sizeOccEnv,
pprOccEnv, forceOccEnv,
intersectOccEnv_C,
@@ -803,6 +804,10 @@ minusOccEnv_C_Ns f (MkOccEnv as) (MkOccEnv bs) =
then Nothing
else Just m
+sizeOccEnv :: OccEnv a -> Int
+sizeOccEnv (MkOccEnv as) =
+ nonDetFoldFsEnv (\ !acc m -> acc + sizeUDFM m) 0 as
+
instance Outputable a => Outputable (OccEnv a) where
ppr x = pprOccEnv ppr x
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4dd98a9a0f6dfcfdd0aabdeb3ad7dd…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4dd98a9a0f6dfcfdd0aabdeb3ad7dd…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc] Pushed new branch wip/romes/more-debugger
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
by Rodrigo Mesquita (@alt-romes) 17 Apr '25
17 Apr '25
Rodrigo Mesquita pushed new branch wip/romes/more-debugger at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/romes/more-debugger
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/fendor/ghci-debugger-unitid] 5 commits: driver: Use ModuleGraph for oneshot and --make mode
by Hannes Siebenhandl (@fendor) 17 Apr '25
by Hannes Siebenhandl (@fendor) 17 Apr '25
17 Apr '25
Hannes Siebenhandl pushed to branch wip/fendor/ghci-debugger-unitid at Glasgow Haskell Compiler / GHC
Commits:
d47bf776 by Matthew Pickering at 2025-04-14T16:44:41+01:00
driver: Use ModuleGraph for oneshot and --make mode
This patch uses the `hsc_mod_graph` field for both oneshot and --make
mode. Therefore, if part of the compiler requires usage of the module
graph, you do so in a uniform way for the two different modes.
The `ModuleGraph` describes the relationship between the modules in the
home package and units in external packages. The `ModuleGraph` can be
queried when information about the transitive closure of a package is
needed. For example, the primary use of the ModuleGraph from within the
compiler is in the loader, which needs to know the transitive closure of
a module so it can load all the relevant objects for evaluation.
In --make mode, downsweep computes the ModuleGraph before any
compilation starts.
In oneshot mode, a thunk is created at the start of compilation, which
when forced will compute the module graph beneath the current module.
The thunk is only forced at the moment when the user uses Template
Haskell.
Finally, there are some situations where we need to discover what
dependencies to load but haven't loaded a module graph at all. In this
case, there is a fallback which computes the transitive closure on the
fly and doesn't cache the result. Presumably if you are going to call
getLinkDeps a lot, you would compute the right ModuleGraph before you
started.
Importantly, this removes the ExternalModuleGraph abstraction. This was quite
awkward to work with since it stored information about the home package
inside the EPS.
This patch will also be very useful when implementing explicit level
imports, which requires more significant use of the module graph in
order to determine which level instances are available at.
Towards #25795
-------------------------
Metric Decrease:
MultiLayerModulesTH_Make
MultiLayerModulesTH_OneShot
-------------------------
- - - - -
395e0ad1 by sheaf at 2025-04-16T12:33:26-04:00
base: remove .Internal modules (e.g. GHC.TypeLits)
This commit removes the following internal modules from base,
as per CLC proposal 217:
- GHC.TypeNats.Internal
- GHC.TypeLits.Internal
- GHC.ExecutionStack.Internal
Fixes #25007
- - - - -
e0f3ff11 by Patrick at 2025-04-17T04:31:12-04:00
Refactor Handling of Multiple Default Declarations
Fixes: #25912, #25914, #25934
Previously, GHC discarded all loaded defaults (tcg_default) when local
defaults were encountered during typechecking. According to the
exportable-named-default proposal (sections 2.4.2 and 2.4.3), local
defaults should be merged into tcg_default, retaining any defaults
already present while overriding where necessary.
Key Changes:
* Introduce DefaultProvenance to track the origin of default declarations
(local, imported, or built-in), replacing the original cd_module
in ClassDefaults with cd_provenance :: DefaultProvenance.
* Rename tcDefaults to tcDefaultDecls, limiting its responsibility to only
converting renamed class defaults into ClassDefaults.
* Add extendDefaultEnvWithLocalDefaults to merge local defaults into the
environment, with proper duplication checks:
- Duplicate local defaults for a class trigger an error.
- Local defaults override imported or built-in defaults.
* Update and add related notes: Note [Builtin class defaults],
Note [DefaultProvenance].
* Add regression tests: T25912, T25914, T25934.
Thanks sam and simon for the help on this patch.
Co-authored-by: sheaf <sam.derbyshire(a)gmail.com>
- - - - -
386f1854 by Teo Camarasu at 2025-04-17T04:31:55-04:00
template-haskell: Remove `addrToByteArrayName` and `addrToByteArray`
These were part of the implementation of the `Lift ByteArray` instance and were errornously exported because this module lacked an explicit export list. They have no usages on Hackage.
Resolves #24782
- - - - -
1828d811 by fendor at 2025-04-17T17:32:25+02:00
Add `UnitId` to `EvalBreakpoint`
The `EvalBreakpoint` is used to communicate that a breakpoint was
encountered during code evaluation.
This `EvalBreakpoint` needs to be converted to an `InternalBreakpointId`
which stores a `Module` to uniquely find the correct `Module` in the
Home Package Table.
The `EvalBreakpoint` used to store only a `ModuleName` which is then
converted to a `Module` based on the currently active home unit.
This is incorrect in the face of multiple home units, the break point
could be in an entirely other home unit!
To fix this, we additionally store the `UnitId` of the `Module` in
`EvalBreakpoint` to later reconstruct the correct `Module`
All of the changes are the consequence of extending `EvalBreakpoint`
with the additional `UnitId`.
- - - - -
66 changed files:
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/Env.hs
- compiler/GHC/Driver/Env/Types.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Errors/Types.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/MakeAction.hs
- + compiler/GHC/Driver/Messager.hs
- compiler/GHC/Driver/Pipeline.hs-boot
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/HsToCore/Breakpoints.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Default.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Types/DefaultEnv.hs
- compiler/GHC/Unit/External.hs
- compiler/GHC/Unit/Finder.hs
- − compiler/GHC/Unit/Module/External/Graph.hs
- compiler/GHC/Unit/Module/Graph.hs
- compiler/GHC/Unit/Module/ModNodeKey.hs
- compiler/ghc.cabal.in
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- − libraries/base/src/GHC/ExecutionStack/Internal.hs
- − libraries/base/src/GHC/TypeLits/Internal.hs
- − libraries/base/src/GHC/TypeNats/Internal.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Run.hs
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- libraries/template-haskell/changelog.md
- rts/Exception.cmm
- rts/Interpreter.c
- + testsuite/tests/default/T25912.hs
- + testsuite/tests/default/T25912.stdout
- + testsuite/tests/default/T25912_helper.hs
- + testsuite/tests/default/T25914.hs
- + testsuite/tests/default/T25934.hs
- testsuite/tests/default/all.T
- testsuite/tests/default/default-fail03.stderr
- + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs
- + testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.stdout
- testsuite/tests/ghc-api/fixed-nodes/all.T
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/linters/notes.stdout
- testsuite/tests/module/mod58.stderr
- testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91cb97034351a26f2162113a877ae2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/91cb97034351a26f2162113a877ae2…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/fendor/ghci-multiple-home-units] Use Module in IIModule
by Hannes Siebenhandl (@fendor) 17 Apr '25
by Hannes Siebenhandl (@fendor) 17 Apr '25
17 Apr '25
Hannes Siebenhandl pushed to branch wip/fendor/ghci-multiple-home-units at Glasgow Haskell Compiler / GHC
Commits:
d0a36c84 by fendor at 2025-04-17T17:31:58+02:00
Use Module in IIModule
- - - - -
8 changed files:
- compiler/GHC.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Runtime/Context.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Unit/Home/Graph.hs
- ghc/GHCi/UI.hs
- testsuite/tests/ghci/linking/dyn/T3372.hs
Changes:
=====================================
compiler/GHC.hs
=====================================
@@ -157,7 +157,7 @@ module GHC (
getBindings, getInsts, getNamePprCtx,
findModule, lookupModule,
findQualifiedModule, lookupQualifiedModule,
- lookupLoadedHomeModuleByModuleName, lookupAnyQualifiedModule,
+ lookupLoadedHomeModuleByModuleName, lookupAllQualifiedModuleNames,
renamePkgQualM, renameRawPkgQualM,
isModuleTrusted, moduleTrustReqs,
getNamesInScope,
@@ -1496,8 +1496,8 @@ getModuleGraph = liftM hsc_mod_graph getSession
-- TODO: this function should likely be deleted.
isLoaded :: GhcMonad m => ModuleName -> m Bool
isLoaded m = withSession $ \hsc_env -> liftIO $ do
- hmi <- HUG.lookupAnyHug (hsc_HUG hsc_env) m
- return $! isJust hmi
+ hmis <- HUG.lookupAllHug (hsc_HUG hsc_env) m
+ return $! not (null hmis)
isLoadedModule :: GhcMonad m => UnitId -> ModuleName -> m Bool
isLoadedModule uid m = withSession $ \hsc_env -> liftIO $ do
@@ -1896,17 +1896,16 @@ lookupLoadedHomeModule uid mod_name = withSession $ \hsc_env -> liftIO $ do
_not_a_home_module -> return Nothing
-- TODO: this is incorrect, what if we have mulitple 'ModuleName's in our HPTs?
-lookupLoadedHomeModuleByModuleName :: GhcMonad m => ModuleName -> m (Maybe Module)
+lookupLoadedHomeModuleByModuleName :: GhcMonad m => ModuleName -> m (Maybe [Module])
lookupLoadedHomeModuleByModuleName mod_name = withSession $ \hsc_env -> liftIO $ do
trace_if (hsc_logger hsc_env) (text "lookupLoadedHomeModuleByModuleName" <+> ppr mod_name)
- HUG.lookupAnyHug (hsc_HUG hsc_env) mod_name >>= \case
- Just mod_info -> return (Just (mi_module (hm_iface mod_info)))
- _not_a_home_module -> return Nothing
+ HUG.lookupAllHug (hsc_HUG hsc_env) mod_name >>= \case
+ [] -> return Nothing
+ mod_infos -> return (Just (mi_module . hm_iface <$> mod_infos))
-lookupAnyQualifiedModule :: GhcMonad m => PkgQual -> ModuleName -> m Module
-lookupAnyQualifiedModule NoPkgQual mod_name = withSession $ \hsc_env -> do
+lookupAllQualifiedModuleNames :: GhcMonad m => PkgQual -> ModuleName -> m [Module]
+lookupAllQualifiedModuleNames NoPkgQual mod_name = withSession $ \hsc_env -> do
home <- lookupLoadedHomeModuleByModuleName mod_name
- liftIO $ trace_if (hsc_logger hsc_env) (ppr home <+> ppr (fmap moduleUnitId home))
case home of
Just m -> return m
Nothing -> liftIO $ do
@@ -1916,11 +1915,12 @@ lookupAnyQualifiedModule NoPkgQual mod_name = withSession $ \hsc_env -> do
let fopts = initFinderOpts dflags
res <- findExposedPackageModule fc fopts units mod_name NoPkgQual
case res of
- Found _ m -> return m
+ Found _ m -> return [m]
err -> throwOneError $ noModError hsc_env noSrcSpan mod_name err
-lookupAnyQualifiedModule pkgqual mod_name =
+lookupAllQualifiedModuleNames pkgqual mod_name = do
-- TODO: definitely wrong.
- findQualifiedModule pkgqual mod_name
+ m <- findQualifiedModule pkgqual mod_name
+ pure [m]
-- | Check that a module is safe to import (according to Safe Haskell).
--
=====================================
compiler/GHC/Rename/Unbound.hs
=====================================
@@ -364,7 +364,7 @@ importSuggestions looking_for ic currMod imports rdr_name
pick_interactive :: InteractiveImport -> Bool
pick_interactive (IIDecl d) | mod_name == Just (unLoc (ideclName d)) = True
| mod_name == fmap unLoc (ideclAs d) = True
- pick_interactive (IIModule m) | mod_name == Just m = True
+ pick_interactive (IIModule m) | mod_name == Just (moduleName m) = True
pick_interactive _ = False
-- We want to keep only one for each original module; preferably one with an
=====================================
compiler/GHC/Runtime/Context.hs
=====================================
@@ -296,9 +296,7 @@ data InteractiveImport
-- ^ Bring the exports of a particular module
-- (filtered by an import decl) into scope
- | IIModule ModuleName
- -- TODO: change this to 'Module', does this work?
- -- Much more precise
+ | IIModule Module
-- ^ Bring into scope the entire top-level envt of
-- of this module, including the things imported
-- into it.
=====================================
compiler/GHC/Runtime/Eval.hs
=====================================
@@ -822,17 +822,12 @@ findGlobalRdrEnv hsc_env imports
idecls :: [LImportDecl GhcPs]
idecls = [noLocA d | IIDecl d <- imports]
- imods :: [ModuleName]
+ imods :: [Module]
imods = [m | IIModule m <- imports]
- mkEnv modl = do
- -- TODO: revisit this, is this how we want to do it?
- mMod <- HUG.lookupAnyHug (hsc_HUG hsc_env) modl
- let mod = case mMod of
- Nothing -> mkModule (RealUnit $ Definite $ hscActiveUnitId hsc_env) modl
- Just m -> mi_module $ hm_iface m
+ mkEnv mod = do
mkTopLevEnv hsc_env mod >>= \case
- Left err -> pure $ Left (modl, err)
+ Left err -> pure $ Left (moduleName mod, err)
Right env -> pure $ Right env
mkTopLevEnv :: HscEnv -> Module -> IO (Either String GlobalRdrEnv)
=====================================
compiler/GHC/Tc/Module.hs
=====================================
@@ -2098,7 +2098,7 @@ runTcInteractive hsc_env thing_inside
; !orphs <- fmap (force . concat) . forM (ic_imports icxt) $ \i ->
case i of -- force above: see #15111
- IIModule n -> getOrphans n NoPkgQual
+ IIModule n -> getOrphans (moduleName n) NoPkgQual -- TODO: wrong
IIDecl i -> getOrphans (unLoc (ideclName i))
(renameRawPkgQual (hsc_unit_env hsc_env) (unLoc $ ideclName i) (ideclPkgQual i))
=====================================
compiler/GHC/Unit/Home/Graph.hs
=====================================
@@ -34,7 +34,7 @@ module GHC.Unit.Home.Graph
, lookupHug
, lookupHugByModule
, lookupHugUnit
- , lookupAnyHug
+ , lookupAllHug
, memberHugHomeModule
, memberHugHomeInstalledModule
@@ -91,6 +91,7 @@ import GHC.Data.Graph.Directed
import GHC.Types.Annotations
import GHC.Types.CompleteMatch
import GHC.Core.InstEnv
+import GHC.Utils.Monad (mapMaybeM)
-- | Get all 'CompleteMatches' (arising from COMPLETE pragmas) present across
@@ -255,21 +256,14 @@ lookupHug hug uid mod = do
Just hue -> lookupHpt (homeUnitEnv_hpt hue) mod
-- TODO: this should not be merged, where else could we try to search for modules?
-lookupAnyHug :: HomeUnitGraph -> ModuleName -> IO (Maybe HomeModInfo)
-lookupAnyHug hug mod = firstJustM $ flip fmap (Set.toList $ unitEnv_keys hug) $ \uid -> do
- case unitEnv_lookup_maybe uid hug of
- -- Really, here we want "lookup HPT" rather than unitEnvLookup
- Nothing -> pure Nothing
- Just hue -> lookupHpt (homeUnitEnv_hpt hue) mod
+lookupAllHug :: HomeUnitGraph -> ModuleName -> IO [HomeModInfo]
+lookupAllHug hug mod = mapMaybeM lookupModuleName (Set.toList $ unitEnv_keys hug)
where
- firstJustM :: Monad f => [f (Maybe a)] -> f (Maybe a)
- firstJustM [] = pure Nothing
- firstJustM (x:xs) = do
- ma <- x
- case ma of
- Nothing -> firstJustM xs
- Just a -> pure $ Just a
-
+ lookupModuleName uid =
+ case unitEnv_lookup_maybe uid hug of
+ -- Really, here we want "lookup HPT" rather than unitEnvLookup
+ Nothing -> pure Nothing
+ Just hue -> lookupHpt (homeUnitEnv_hpt hue) mod
-- | Lookup the 'HomeModInfo' of a 'Module' in the 'HomeUnitGraph' (via the 'HomePackageTable' of the corresponding unit)
lookupHugByModule :: Module -> HomeUnitGraph -> IO (Maybe HomeModInfo)
=====================================
ghc/GHCi/UI.hs
=====================================
@@ -558,7 +558,7 @@ interactiveUI config srcs maybe_exprs = do
hsc_env <- GHC.getSession
let !in_multi = length (hsc_all_home_unit_ids hsc_env) > 3
-- We force this to make sure we don't retain the hsc_env when reloading
- -- The check is `> 2`, since we now always have at least two home units.
+ -- The check is `> 3`, since we now always have at least two home units.
-- TODO: if everything goes well, this check should be deleted once
-- this PR has lifted the multiple home unit restrictions
empty_cache <- liftIO newIfaceCache
@@ -1023,7 +1023,7 @@ getInfoForPrompt = do
| otherwise = unLoc (ideclName d)
modules_names =
- ['*':(moduleNameString m) | IIModule m <- rev_imports] ++
+ ['*':(moduleNameString (moduleName m)) | IIModule m <- rev_imports] ++
[moduleNameString (myIdeclName d) | IIDecl d <- rev_imports]
line = 1 + line_number st
@@ -2279,7 +2279,7 @@ setContextAfterLoad keep_ctxt (Just graph) = do
-- We import the module with a * iff
-- - it is interpreted, and
-- - -XSafe is off (it doesn't allow *-imports)
- let new_ctx | star_ok = [mkIIModule (GHC.moduleName m)]
+ let new_ctx | star_ok = [mkIIModule m]
| otherwise = [mkIIDecl (GHC.moduleName m)]
setContextKeepingPackageModules keep_ctxt new_ctx
@@ -2699,7 +2699,7 @@ guessCurrentModule cmd = do
imports <- GHC.getContext
case imports of
[] -> throwGhcException $ CmdLineError (':' : cmd ++ ": no current module")
- IIModule m : _ -> GHC.findQualifiedModule NoPkgQual m
+ IIModule m : _ -> pure m
IIDecl d : _ -> do
pkgqual <- GHC.renameRawPkgQualM (unLoc $ ideclName d) (ideclPkgQual d)
GHC.findQualifiedModule pkgqual (unLoc (ideclName d))
@@ -2829,8 +2829,9 @@ addModulesToContext starred unstarred = restoreContextOnFailure $ do
addModulesToContext_ :: GhciMonad m => [ModuleName] -> [ModuleName] -> m ()
addModulesToContext_ starred unstarred = do
- mapM_ addII (map mkIIModule starred ++ map mkIIDecl unstarred)
- setGHCContextFromGHCiState
+ starredModules <- traverse lookupModuleName starred
+ mapM_ addII (map mkIIModule starredModules ++ map mkIIDecl unstarred)
+ setGHCContextFromGHCiState
remModulesFromContext :: GhciMonad m => [ModuleName] -> [ModuleName] -> m ()
remModulesFromContext starred unstarred = do
@@ -2896,9 +2897,9 @@ checkAdd ii = do
dflags <- getDynFlags
let safe = safeLanguageOn dflags
case ii of
- IIModule modname
+ IIModule mod
| safe -> throwGhcException $ CmdLineError "can't use * imports with Safe Haskell"
- | otherwise -> wantInterpretedModuleName modname >> return ()
+ | otherwise -> checkInterpretedModule mod >> return ()
IIDecl d -> do
let modname = unLoc (ideclName d)
@@ -2966,13 +2967,13 @@ getImplicitPreludeImports iidecls = do
-- -----------------------------------------------------------------------------
-- Utils on InteractiveImport
-mkIIModule :: ModuleName -> InteractiveImport
+mkIIModule :: Module -> InteractiveImport
mkIIModule = IIModule
mkIIDecl :: ModuleName -> InteractiveImport
mkIIDecl = IIDecl . simpleImportDecl
-iiModules :: [InteractiveImport] -> [ModuleName]
+iiModules :: [InteractiveImport] -> [Module]
iiModules is = [m | IIModule m <- is]
isIIModule :: InteractiveImport -> Bool
@@ -2980,7 +2981,7 @@ isIIModule (IIModule _) = True
isIIModule _ = False
iiModuleName :: InteractiveImport -> ModuleName
-iiModuleName (IIModule m) = m
+iiModuleName (IIModule m) = moduleName m
iiModuleName (IIDecl d) = unLoc (ideclName d)
preludeModuleName :: ModuleName
@@ -3428,7 +3429,7 @@ showImports = do
trans_ctx = transient_ctx st
show_one (IIModule star_m)
- = ":module +*" ++ moduleNameString star_m
+ = ":module +*" ++ moduleNameString (moduleName star_m)
show_one (IIDecl imp) = showPpr dflags imp
prel_iidecls <- getImplicitPreludeImports (rem_ctx ++ trans_ctx)
@@ -3734,11 +3735,11 @@ completeBreakpoint = wrapCompleter spaces $ \w -> do -- #3000
filterM GHC.moduleIsInterpreted hmods
-- Return all possible bids for a given Module
- bidsByModule :: GhciMonad m => [ModuleName] -> Module -> m [String]
+ bidsByModule :: GhciMonad m => [Module] -> Module -> m [String]
bidsByModule nonquals mod = do
(_, decls) <- getModBreak mod
let bids = nub $ declPath <$> elems decls
- pure $ case (moduleName mod) `elem` nonquals of
+ pure $ case mod `elem` nonquals of
True -> bids
False -> (combineModIdent (showModule mod)) <$> bids
@@ -4143,8 +4144,7 @@ breakSwitch (arg1:rest)
| all isDigit arg1 = do
imports <- GHC.getContext
case iiModules imports of
- (mn : _) -> do
- md <- lookupModuleName mn
+ (md : _) -> do
breakByModuleLine md (read arg1) rest
[] -> do
liftIO $ putStrLn "No modules are loaded with debugging support."
@@ -4276,8 +4276,7 @@ list2 [arg] | all isDigit arg = do
case iiModules imports of
[] -> liftIO $ putStrLn "No module to list"
(mn : _) -> do
- md <- lookupModuleName mn
- listModuleLine md (read arg)
+ listModuleLine mn (read arg)
list2 [arg1,arg2] | looksLikeModuleName arg1, all isDigit arg2 = do
md <- wantInterpretedModule arg1
listModuleLine md (read arg2)
@@ -4536,7 +4535,17 @@ lookupModuleName :: GHC.GhcMonad m => ModuleName -> m Module
lookupModuleName mName = lookupQualifiedModuleName NoPkgQual mName
lookupQualifiedModuleName :: GHC.GhcMonad m => PkgQual -> ModuleName -> m Module
-lookupQualifiedModuleName = GHC.lookupAnyQualifiedModule
+lookupQualifiedModuleName qual modl = do
+ GHC.lookupAllQualifiedModuleNames qual modl >>= \case
+ [] -> throwGhcException (CmdLineError ("module '" ++ str ++ "' could not be found."))
+ [m] -> pure m
+ ms -> throwGhcException (CmdLineError ("module name '" ++ str ++ "' is ambiguous;\n" ++ errorMsg ms))
+ where
+ str = moduleNameString modl
+ errorMsg ms = intercalate "\n"
+ [ "- " ++ unitIdString (toUnitId (moduleUnit m)) ++ ":" ++ moduleNameString (moduleName m)
+ | m <- ms
+ ]
isMainUnitModule :: Module -> Bool
isMainUnitModule m = GHC.moduleUnit m == mainUnit
@@ -4586,15 +4595,19 @@ wantInterpretedModule str = wantInterpretedModuleName (GHC.mkModuleName str)
wantInterpretedModuleName :: GHC.GhcMonad m => ModuleName -> m Module
wantInterpretedModuleName modname = do
- modl <- lookupModuleName modname
- let str = moduleNameString modname
- hug <- hsc_HUG <$> GHC.getSession
- unless (HUG.memberHugHomeModule modl hug) $
- throwGhcException (CmdLineError ("module '" ++ str ++ "' is from another package;\nthis command requires an interpreted module"))
- is_interpreted <- GHC.moduleIsInterpreted modl
- when (not is_interpreted) $
- throwGhcException (CmdLineError ("module '" ++ str ++ "' is not interpreted; try \':add *" ++ str ++ "' first"))
- return modl
+ modl <- lookupModuleName modname
+ checkInterpretedModule modl
+
+checkInterpretedModule :: GHC.GhcMonad m => Module -> m Module
+checkInterpretedModule modl = do
+ let str = moduleNameString $ moduleName modl
+ hug <- hsc_HUG <$> GHC.getSession
+ unless (HUG.memberHugHomeModule modl hug) $
+ throwGhcException (CmdLineError ("module '" ++ str ++ "' is from another package;\nthis command requires an interpreted module"))
+ is_interpreted <- GHC.moduleIsInterpreted modl
+ when (not is_interpreted) $
+ throwGhcException (CmdLineError ("module '" ++ str ++ "' is not interpreted; try \':add *" ++ str ++ "' first"))
+ return modl
wantNameFromInterpretedModule :: GHC.GhcMonad m
=> (Name -> SDoc -> m ())
=====================================
testsuite/tests/ghci/linking/dyn/T3372.hs
=====================================
@@ -60,7 +60,7 @@ load (f,mn) = do target <- GHC.guessTarget f Nothing Nothing
GHC.liftIO $ putStrLn ("Load " ++ showSuccessFlag res)
--
m <- GHC.findModule (GHC.mkModuleName mn) Nothing
- GHC.setContext [GHC.IIModule $ GHC.moduleName $ m]
+ GHC.setContext [GHC.IIModule m]
where showSuccessFlag GHC.Succeeded = "succeeded"
showSuccessFlag GHC.Failed = "failed"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0a36c84651dee8ff3dd198a167b334…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0a36c84651dee8ff3dd198a167b334…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/splice-imports-2025] 3 commits: More stage -> level
by Matthew Pickering (@mpickering) 17 Apr '25
by Matthew Pickering (@mpickering) 17 Apr '25
17 Apr '25
Matthew Pickering pushed to branch wip/splice-imports-2025 at Glasgow Haskell Compiler / GHC
Commits:
5e145778 by Matthew Pickering at 2025-04-17T15:37:32+01:00
More stage -> level
- - - - -
be437442 by Matthew Pickering at 2025-04-17T15:42:05+01:00
Remove quoted name wrong stage error
- - - - -
88820305 by Matthew Pickering at 2025-04-17T15:44:55+01:00
fix note references
- - - - -
23 changed files:
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/TH.hs
- compiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Types/Error/Codes.hs
Changes:
=====================================
compiler/GHC/Rename/Env.hs
=====================================
@@ -238,8 +238,8 @@ newTopSrcBinder (L loc rdr_name)
-- Binders should not be qualified; if they are, and with a different
-- module name, we get a confusing "M.T is not in scope" error later
- ; stage <- getStage
- ; if isBrackStage stage then
+ ; level <- getThLevel
+ ; if isBrackLevel level then
-- We are inside a TH bracket, so make an *Internal* name
-- See Note [Top-level Names in Template Haskell decl quotes] in GHC.Rename.Names
do { uniq <- newUnique
@@ -1015,7 +1015,7 @@ lookupLocalOccRn_maybe rdr_name
= do { local_env <- getLocalRdrEnv
; return (lookupLocalRdrEnv local_env rdr_name) }
-lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevel))
+lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevelIndex))
-- Just look in the local environment
lookupLocalOccThLvl_maybe name
= do { lcl_env <- getLclEnv
=====================================
compiler/GHC/Rename/Expr.hs
=====================================
@@ -33,7 +33,7 @@ import GHC.Prelude hiding (head, init, last, scanl, tail)
import GHC.Hs
import GHC.Tc.Errors.Types
-import GHC.Tc.Utils.Env ( isBrackStage )
+import GHC.Tc.Utils.Env ( isBrackLevel )
import GHC.Tc.Utils.Monad
import GHC.Rename.Bind ( rnLocalBindsAndThen, rnLocalValBindsLHS, rnLocalValBindsRHS
@@ -656,8 +656,8 @@ rnExpr e@(HsStatic _ expr) = do
unlessXOptM LangExt.StaticPointers $
addErr $ TcRnIllegalStaticExpression e
(expr',fvExpr) <- rnLExpr expr
- stage <- getStage
- case stage of
+ level <- getThLevel
+ case level of
Splice _ _ -> addErr $ TcRnTHError $ IllegalStaticFormInSplice e
_ -> return ()
mod <- getModule
@@ -1152,7 +1152,7 @@ postProcessStmtsForApplicativeDo ctxt stmts
| otherwise = False
-- don't apply the transformation inside TH brackets, because
-- GHC.HsToCore.Quote does not handle ApplicativeDo.
- ; in_th_bracket <- isBrackStage <$> getStage
+ ; in_th_bracket <- isBrackLevel <$> getThLevel
; if ado_is_on && is_do_expr && not in_th_bracket
then do { traceRn "ppsfa" (ppr stmts)
; rearrangeForApplicativeDo ctxt stmts }
=====================================
compiler/GHC/Rename/Module.hs
=====================================
@@ -348,8 +348,8 @@ rnAnnDecl :: AnnDecl GhcPs -> RnM (AnnDecl GhcRn, FreeVars)
rnAnnDecl ann@(HsAnnotation (_, s) provenance expr)
= addErrCtxt (AnnCtxt ann) $
do { (provenance', provenance_fvs) <- rnAnnProvenance provenance
- ; cur_stage <- getStage
- ; (expr', expr_fvs) <- setStage (Splice Untyped cur_stage) $
+ ; cur_level <- getThLevel
+ ; (expr', expr_fvs) <- setThLevel (Splice Untyped cur_level) $
rnLExpr expr
; return (HsAnnotation (noAnn, s) provenance' expr',
provenance_fvs `plusFV` expr_fvs) }
=====================================
compiler/GHC/Rename/Names.hs
=====================================
@@ -635,7 +635,7 @@ top level binders specially in two ways
See Note [GlobalRdrEnv shadowing]
3. We find out whether we are inside a [d| ... |] by testing the TH
- stage. This is a slight hack, because the stage field was really
+ level. This is a slight hack, because the level field was really
meant for the type checker, and here we are not interested in the
fields of Brack, hence the error thunks in thRnBrack.
-}
@@ -651,18 +651,18 @@ extendGlobalRdrEnvRn :: [GlobalRdrElt]
extendGlobalRdrEnvRn new_gres new_fixities
= checkNoErrs $ -- See Note [Fail fast on duplicate definitions]
do { (gbl_env, lcl_env) <- getEnvs
- ; stage <- getStage
+ ; level <- getThLevel
; isGHCi <- getIsGHCi
; let rdr_env = tcg_rdr_env gbl_env
fix_env = tcg_fix_env gbl_env
th_bndrs = getLclEnvThBndrs lcl_env
- th_lvl = thLevel stage
+ th_lvl = thLevelIndex level
-- Delete new_occs from global and local envs
-- If we are in a TemplateHaskell decl bracket,
-- we are going to shadow them
-- See Note [GlobalRdrEnv shadowing]
- inBracket = isBrackStage stage
+ inBracket = isBrackLevel level
lcl_env_TH = modifyLclCtxt (\lcl_env -> lcl_env { tcl_rdr = minusLocalRdrEnv (tcl_rdr lcl_env) new_gres_env }) lcl_env
-- See Note [GlobalRdrEnv shadowing]
=====================================
compiler/GHC/Rename/Splice.hs
=====================================
@@ -124,8 +124,8 @@ rnTypedBracket e br_body
do { checkForTemplateHaskellQuotes e
-- Check for nested brackets
- ; cur_stage <- getStage
- ; case cur_stage of
+ ; cur_level <- getThLevel
+ ; case cur_level of
{ Splice _ _ -> return ()
-- See Note [Untyped quotes in typed splices and vice versa]
; RunSplice _ ->
@@ -141,7 +141,7 @@ rnTypedBracket e br_body
; recordThUse
; traceRn "Renaming typed TH bracket" empty
- ; (body', fvs_e) <- setStage (Brack cur_stage RnPendingTyped) $ rnLExpr br_body
+ ; (body', fvs_e) <- setThLevel (Brack cur_level RnPendingTyped) $ rnLExpr br_body
; return (HsTypedBracket noExtField body', fvs_e)
@@ -153,8 +153,8 @@ rnUntypedBracket e br_body
do { checkForTemplateHaskellQuotes e
-- Check for nested brackets
- ; cur_stage <- getStage
- ; case cur_stage of
+ ; cur_level <- getThLevel
+ ; case cur_level of
{ Splice _ _ -> return ()
-- See Note [Untyped quotes in typed splices and vice versa]
; RunSplice _ ->
@@ -174,7 +174,7 @@ rnUntypedBracket e br_body
; (body', fvs_e) <-
-- See Note [Rebindable syntax and Template Haskell]
unsetXOptM LangExt.RebindableSyntax $
- setStage (Brack cur_stage (RnPendingUntyped ps_var)) $
+ setThLevel (Brack cur_level (RnPendingUntyped ps_var)) $
rn_utbracket br_body
; pendings <- readMutVar ps_var
; return (HsUntypedBracket pendings body', fvs_e)
@@ -279,14 +279,14 @@ rnUntypedSpliceGen :: (HsUntypedSplice GhcRn -> RnM (a, FreeVars))
-> RnM (a, FreeVars)
rnUntypedSpliceGen run_splice pend_splice splice
= addErrCtxt (UntypedSpliceCtxt splice) $ do
- { stage <- getStage
- ; case stage of
+ { level <- getThLevel
+ ; case level of
Brack _ RnPendingTyped
-> failWithTc $ thSyntaxError
$ MismatchedSpliceType Untyped IsSplice
- Brack pop_stage (RnPendingUntyped ps_var)
- -> do { (splice', fvs) <- setStage pop_stage $
+ Brack pop_level (RnPendingUntyped ps_var)
+ -> do { (splice', fvs) <- setThLevel pop_level $
rnUntypedSplice splice
; loc <- getSrcSpanM
; splice_name <- newLocalBndrRn (L (noAnnSrcSpan loc) unqualSplice)
@@ -296,9 +296,9 @@ rnUntypedSpliceGen run_splice pend_splice splice
; return (result, fvs) }
_ -> do { checkTopSpliceAllowed splice
- ; cur_stage <- getStage
+ ; cur_level <- getThLevel
; (splice', fvs1) <- checkNoErrs $
- setStage (Splice Untyped cur_stage) $
+ setThLevel (Splice Untyped cur_level) $
rnUntypedSplice splice
-- checkNoErrs: don't attempt to run the splice if
-- renaming it failed; otherwise we get a cascade of
@@ -350,7 +350,7 @@ runRnSplice flavour run_meta ppr_res splice
-- Run the expression
; mod_finalizers_ref <- newTcRef []
- ; result <- setStage (RunSplice mod_finalizers_ref) $
+ ; result <- setThLevel (RunSplice mod_finalizers_ref) $
run_meta zonked_q_expr
; mod_finalizers <- readTcRef mod_finalizers_ref
; traceSplice (SpliceInfo { spliceDescription = what
@@ -434,10 +434,10 @@ rnTypedSplice :: LHsExpr GhcPs -- Typed splice expression
-> RnM (HsExpr GhcRn, FreeVars)
rnTypedSplice expr
= addErrCtxt (TypedSpliceCtxt Nothing expr) $ do
- { stage <- getStage
- ; case stage of
- Brack pop_stage RnPendingTyped
- -> setStage pop_stage rn_splice
+ { level <- getThLevel
+ ; case level of
+ Brack pop_level RnPendingTyped
+ -> setThLevel pop_level rn_splice
Brack _ (RnPendingUntyped _)
-> failWithTc $ thSyntaxError $ MismatchedSpliceType Typed IsSplice
@@ -445,8 +445,8 @@ rnTypedSplice expr
_ -> do { unlessXOptM LangExt.TemplateHaskell
(failWith $ thSyntaxError IllegalTHSplice)
- ; cur_stage <- getStage
- ; (result, fvs1) <- checkNoErrs $ setStage (Splice Typed cur_stage) rn_splice
+ ; cur_level <- getThLevel
+ ; (result, fvs1) <- checkNoErrs $ setThLevel (Splice Typed cur_level) rn_splice
-- checkNoErrs: don't attempt to run the splice if
-- renaming it failed; otherwise we get a cascade of
-- errors from e.g. unbound variables
@@ -790,9 +790,9 @@ rnTopSpliceDecls :: HsUntypedSplice GhcPs -> RnM ([LHsDecl GhcPs], FreeVars)
-- Declaration splice at the very top level of the module
rnTopSpliceDecls splice
= do { checkTopSpliceAllowed splice
- ; cur_stage <- getStage
+ ; cur_level <- getThLevel
; (rn_splice, fvs) <- checkNoErrs $
- setStage (Splice Untyped cur_stage) $
+ setThLevel (Splice Untyped cur_level) $
rnUntypedSplice splice
-- As always, be sure to checkNoErrs above lest we end up with
-- holes making it to typechecking, hence #12584.
@@ -909,27 +909,25 @@ checkThLocalTyName name
| otherwise
= do { traceRn "checkThLocalTyName" (ppr name)
- ; mb_local_use <- getStageAndBindLevel name
+ ; mb_local_use <- getCurrentAndBindLevel name
; case mb_local_use of {
Nothing -> return () ; -- Not a locally-bound thing
- Just (top_lvl, bind_lvl, use_stage) ->
- do { let use_lvl = thLevel use_stage
- -- We don't check the well stageness of name here.
+ Just (top_lvl, bind_lvl, use_lvl) ->
+ do { let use_lvl_idx = thLevelIndex use_lvl
+ -- We don't check the well levelledness of name here.
-- this would break test for #20969
--
-- Consequently there is no check&restiction for top level splices.
-- But it's annoying anyway.
--
- -- Therefore checkCrossStageLiftingTy shouldn't assume anything
+ -- Therefore checkCrossLevelLiftingTy shouldn't assume anything
-- about bind_lvl and use_lvl relation.
--
- -- ; checkWellStaged (StageCheckSplice name) bind_lvl use_lvl
-
; traceRn "checkThLocalTyName" (ppr name <+> ppr bind_lvl
- <+> ppr use_stage
+ <+> ppr use_lvl
<+> ppr use_lvl)
; dflags <- getDynFlags
- ; checkCrossStageLiftingTy dflags top_lvl bind_lvl use_stage use_lvl name } } }
+ ; checkCrossLevelLiftingTy dflags top_lvl bind_lvl use_lvl use_lvl_idx name } } }
-- | Check whether we are allowed to use a Name in this context (for TH purposes)
-- In the case of a level incorrect program, attempt to fix it by using
@@ -953,34 +951,34 @@ checkThLocalName allow_lifting name
| otherwise
= do {
- mb_local_use <- getStageAndBindLevel name
+ mb_local_use <- getCurrentAndBindLevel name
; case mb_local_use of {
Nothing -> return () ; -- Not a locally-bound thing
- Just (top_lvl, bind_lvl, use_stage) ->
- do { let use_lvl = thLevel use_stage
+ Just (top_lvl, bind_lvl, use_lvl) ->
+ do { let use_lvl_idx = thLevelIndex use_lvl
; cur_mod <- extractModule <$> getGblEnv
; let is_local
| Just mod <- nameModule_maybe name = mod == cur_mod
| otherwise = True
- ; traceRn "checkThLocalName" (ppr name <+> ppr bind_lvl <+> ppr use_lvl <+> ppr use_stage)
+ ; traceRn "checkThLocalName" (ppr name <+> ppr bind_lvl <+> ppr use_lvl <+> ppr use_lvl)
; dflags <- getDynFlags
; env <- getGlobalRdrEnv
; let mgre = lookupGRE_Name env name
- ; checkCrossStageLifting dflags (StageCheckSplice name mgre) top_lvl is_local allow_lifting bind_lvl use_stage use_lvl name } } }
+ ; checkCrossLevelLifting dflags (LevelCheckSplice name mgre) top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name } } }
--------------------------------------
-checkCrossStageLifting :: DynFlags
- -> StageCheckReason
+checkCrossLevelLifting :: DynFlags
+ -> LevelCheckReason
-> TopLevelFlag
-> Bool
-> Bool
- -> Set.Set ThLevel
- -> ThStage
+ -> Set.Set ThLevelIndex
-> ThLevel
+ -> ThLevelIndex
-> Name -> TcM ()
-checkCrossStageLifting dflags reason top_lvl is_local allow_lifting bind_lvl use_stage use_lvl name
+checkCrossLevelLifting dflags reason top_lvl is_local allow_lifting bind_lvl use_lvl use_lvl_idx name
-- 1. If name is in-scope, at the correct level.
- | use_lvl `Set.member` bind_lvl = return ()
+ | use_lvl_idx `Set.member` bind_lvl = return ()
-- 2. Name is imported with -XImplicitStagePersistence
| not is_local
, xopt LangExt.ImplicitStagePersistence dflags = return ()
@@ -988,23 +986,23 @@ checkCrossStageLifting dflags reason top_lvl is_local allow_lifting bind_lvl use
-- to be persisted into the future.
| isTopLevel top_lvl
, is_local
- , any (use_lvl >=) (Set.toList bind_lvl)
+ , any (use_lvl_idx >=) (Set.toList bind_lvl)
, xopt LangExt.ImplicitStagePersistence dflags = when (isExternalName name) (keepAlive name)
-- 4. Name is in an untyped bracket, and we are allowed to attempt to lift.
- | Brack _ (RnPendingUntyped ps_var) <- use_stage -- Only for untyped brackets
+ | Brack _ (RnPendingUntyped ps_var) <- use_lvl -- Only for untyped brackets
, allow_lifting
= do
dflags <- getDynFlags
- check_cross_stage_lifting dflags top_lvl name ps_var
+ check_cross_level_lifting dflags top_lvl name ps_var
-- 5. For an typed bracket, these checks happen again later on (checkThLocalId)
-- In the future we should do all the level checks here.
- | Brack _ RnPendingTyped <- use_stage -- Lift for typed brackets is inserted later.
+ | Brack _ RnPendingTyped <- use_lvl -- Lift for typed brackets is inserted later.
= return ()
-- Otherwise, we have a level error, report.
- | otherwise = addErrTc (TcRnBadlyLevelled reason bind_lvl use_lvl)
+ | otherwise = addErrTc (TcRnBadlyLevelled reason bind_lvl use_lvl_idx)
-check_cross_stage_lifting :: DynFlags -> TopLevelFlag -> Name -> TcRef [PendingRnSplice] -> TcM ()
-check_cross_stage_lifting dflags top_lvl name ps_var
+check_cross_level_lifting :: DynFlags -> TopLevelFlag -> Name -> TcRef [PendingRnSplice] -> TcM ()
+check_cross_level_lifting dflags top_lvl name ps_var
| isTopLevel top_lvl
, xopt LangExt.ImplicitStagePersistence dflags
-- Top-level identifiers in this module,
@@ -1027,7 +1025,7 @@ check_cross_stage_lifting dflags top_lvl name ps_var
-- If 'x' occurs many times we may get many identical
-- bindings of the same SplicePointName, but that doesn't
-- matter, although it's a mite untidy.
- do { traceRn "checkCrossStageLifting" (ppr name)
+ do { traceRn "checkCrossLevelLifting" (ppr name)
-- Construct the (lift x) expression
; let lift_expr = nlHsApp (nlHsVar liftName) (nlHsVar name)
@@ -1040,8 +1038,8 @@ check_cross_stage_lifting dflags top_lvl name ps_var
; ps <- readMutVar ps_var
; writeMutVar ps_var (pend_splice : ps) }
-checkCrossStageLiftingTy :: DynFlags -> TopLevelFlag -> Set.Set ThLevel -> ThStage -> ThLevel -> Name -> TcM ()
-checkCrossStageLiftingTy dflags top_lvl bind_lvl _use_stage use_lvl name
+checkCrossLevelLiftingTy :: DynFlags -> TopLevelFlag -> Set.Set ThLevelIndex -> ThLevel -> ThLevelIndex -> Name -> TcM ()
+checkCrossLevelLiftingTy dflags top_lvl bind_lvl _use_lvl use_lvl_idx name
| isTopLevel top_lvl
, xopt LangExt.ImplicitStagePersistence dflags
= return ()
@@ -1052,8 +1050,8 @@ checkCrossStageLiftingTy dflags top_lvl bind_lvl _use_stage use_lvl name
-- Can also happen for negative cases
-- See comment in checkThLocalTyName:
- | use_lvl `notElem` bind_lvl
- = addDiagnostic $ TcRnBadlyLevelledType name bind_lvl use_lvl
+ | use_lvl_idx `notElem` bind_lvl
+ = addDiagnostic $ TcRnBadlyLevelledType name bind_lvl use_lvl_idx
| otherwise
= return ()
@@ -1094,7 +1092,7 @@ them in the keep-alive set.
Note [Quoting names]
~~~~~~~~~~~~~~~~~~~~
A quoted name 'n is a bit like a quoted expression [| n |], except that we
-have no cross-stage lifting (c.f. GHC.Tc.Gen.Expr.thBrackId). So, after incrementing
+have no cross-level lifting (c.f. GHC.Tc.Gen.Expr.thBrackId). So, after incrementing
the use-level to account for the brackets, the cases are:
bind > use Error
@@ -1113,7 +1111,7 @@ Examples:
\x. f 'x -- Not ok (bind = 1, use = 1)
-- (whereas \x. f [| x |] might have been ok, by
- -- cross-stage lifting
+ -- cross-level lifting
\y. [| \x. $(f 'y) |] -- Not ok (bind =1, use = 1)
=====================================
compiler/GHC/Rename/Utils.hs
=====================================
@@ -106,7 +106,7 @@ newLocalBndrsRn = mapM newLocalBndrRn
bindLocalNames :: [Name] -> RnM a -> RnM a
bindLocalNames names
= updLclCtxt $ \ lcl_env ->
- let th_level = thLevel (tcl_th_ctxt lcl_env)
+ let th_level = thLevelIndex (tcl_th_ctxt lcl_env)
th_bndrs' = extendNameEnvList (tcl_th_bndrs lcl_env)
[ (n, (NotTopLevel, th_level)) | n <- names ]
rdr_env' = extendLocalRdrEnvList (tcl_rdr lcl_env) names
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -1510,17 +1510,17 @@ instance Diagnostic TcRnMessage where
TcRnBadlyLevelled reason bind_lvl use_lvl
-> mkSimpleDecorated $
vcat $
- [ text "Level error:" <+> pprStageCheckReason reason <+>
+ [ text "Level error:" <+> pprLevelCheckReason reason <+>
hsep [text "is bound at level" <+> ppr bind_lvl,
text "but used at level" <+> ppr use_lvl]
] ++
[ hsep [ text "Hint: quoting" <+> thBrackets (ppUnless (isValName n) "t") (ppr n)
, text "or an enclosing expression would allow the quotation to be used at an earlier level"
]
- | StageCheckSplice n _ <- [reason]
+ | LevelCheckSplice n _ <- [reason]
] ++
[ "From imports" <+> (ppr (gre_imp gre))
- | StageCheckSplice _ (Just gre) <- [reason]
+ | LevelCheckSplice _ (Just gre) <- [reason]
, not (isEmptyBag (gre_imp gre)) ]
TcRnBadlyLevelledType name bind_lvl use_lvl
-> mkSimpleDecorated $
@@ -5770,11 +5770,11 @@ pprWrongThingSort =
WrongThingTyCon -> "type constructor"
WrongThingAxiom -> "axiom"
-pprStageCheckReason :: StageCheckReason -> SDoc
-pprStageCheckReason = \case
- StageCheckInstance _ t ->
+pprLevelCheckReason :: LevelCheckReason -> SDoc
+pprLevelCheckReason = \case
+ LevelCheckInstance _ t ->
text "instance for" <+> quotes (ppr t)
- StageCheckSplice t _ ->
+ LevelCheckSplice t _ ->
quotes (ppr t)
pprUninferrableTyVarCtx :: UninferrableTyVarCtx -> SDoc
@@ -6877,10 +6877,6 @@ pprTHNameError = \case
mkSimpleDecorated $
hang (text "The binder" <+> quotes (ppr name) <+> text "is not a NameU.")
2 (text "Probable cause: you used mkName instead of newName to generate a binding.")
- QuotedNameWrongStage quote ->
- mkSimpleDecorated $
- sep [ text "Stage error: the non-top-level quoted name" <+> ppr quote
- , text "must be used at the same stage at which it is bound." ]
pprTHReifyError :: THReifyError -> DecoratedSDoc
pprTHReifyError = \case
@@ -7002,7 +6998,6 @@ thSyntaxErrorReason = \case
thNameErrorReason :: THNameError -> DiagnosticReason
thNameErrorReason = \case
NonExactName {} -> ErrorWithoutFlag
- QuotedNameWrongStage {} -> ErrorWithoutFlag
thReifyErrorReason :: THReifyError -> DiagnosticReason
thReifyErrorReason = \case
@@ -7063,7 +7058,6 @@ thSyntaxErrorHints = \case
thNameErrorHints :: THNameError -> [GhcHint]
thNameErrorHints = \case
NonExactName {} -> noHints
- QuotedNameWrongStage {} -> noHints
thReifyErrorHints :: THReifyError -> [GhcHint]
thReifyErrorHints = \case
=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -99,7 +99,7 @@ module GHC.Tc.Errors.Types (
, RuleLhsErrReason(..)
, HsigShapeMismatchReason(..)
, WrongThingSort(..)
- , StageCheckReason(..)
+ , LevelCheckReason(..)
, UninferrableTyVarCtx(..)
, PatSynInvalidRhsReason(..)
, BadFieldAnnotationReason(..)
@@ -3487,19 +3487,19 @@ data TcRnMessage where
-> !LookupInstanceErrReason
-> TcRnMessage
- {-| TcRnBadlyStaged is an error that occurs when a TH binding is used at an
+ {-| TcRnBadlyLevelled is an error that occurs when a TH binding is used at an
invalid level.
Test cases:
T17820d, T17820, T21547, T5795, qq00[1-4], annfail0{3,4,6,9}
-}
TcRnBadlyLevelled
- :: !StageCheckReason -- ^ The binding
- -> !(Set.Set Int) -- ^ The binding levels
- -> !Int -- ^ The level at which the binding is used.
+ :: !LevelCheckReason -- ^ The binding
+ -> !(Set.Set ThLevelIndex) -- ^ The binding levels
+ -> !ThLevelIndex -- ^ The level at which the binding is used.
-> TcRnMessage
- {-| TcRnBadlyStagedWarn is a warning that occurs when a TH type binding is
+ {-| TcRnBadlyLevelledWarn is a warning that occurs when a TH type binding is
used in an invalid stage.
Controlled by flags:
@@ -3510,8 +3510,8 @@ data TcRnMessage where
-}
TcRnBadlyLevelledType
:: !Name -- ^ The type binding being spliced.
- -> !(Set.Set Int) -- ^ The binding stage.
- -> !Int -- ^ The stage at which the binding is used.
+ -> !(Set.Set ThLevelIndex) -- ^ The binding stage.
+ -> !ThLevelIndex -- ^ The stage at which the binding is used.
-> TcRnMessage
{-| TcRnTyThingUsedWrong is an error that occurs when a thing is used where another
@@ -6245,9 +6245,9 @@ data WrongThingSort
| WrongThingTyCon
| WrongThingAxiom
-data StageCheckReason
- = StageCheckInstance !InstanceWhat !PredType
- | StageCheckSplice !Name !(Maybe GlobalRdrElt)
+data LevelCheckReason
+ = LevelCheckInstance !InstanceWhat !PredType
+ | LevelCheckSplice !Name !(Maybe GlobalRdrElt)
data UninferrableTyVarCtx
= UninfTyCtx_ClassContext [TcType]
@@ -6745,13 +6745,6 @@ data THNameError
-}
= NonExactName !RdrName
- {-| QuotedNameWrongStage is an error that can happen when a
- (non-top-level) Name is used at a different Template Haskell stage
- than the stage at which it is bound.
-
- Test cases: T16976z
- -}
- | QuotedNameWrongStage !(HsQuote GhcPs)
deriving Generic
data THReifyError
=====================================
compiler/GHC/Tc/Gen/App.hs
=====================================
@@ -1217,13 +1217,13 @@ tc_inst_forall_arg conc_tvs (tvb, inner_ty) hs_ty
--
-- See [Wrinkle: VTA] in Note [Representation-polymorphism checking built-ins]
-- in GHC.Tc.Utils.Concrete.
- ; th_stage <- getStage
+ ; th_lvl <- getThLevel
; ty_arg <- case mb_conc of
Nothing -> return ty_arg0
Just conc
-- See [Wrinkle: Typed Template Haskell]
-- in Note [hasFixedRuntimeRep] in GHC.Tc.Utils.Concrete.
- | Brack _ (TcPending {}) <- th_stage
+ | Brack _ (TcPending {}) <- th_lvl
-> return ty_arg0
| otherwise
->
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -1075,28 +1075,28 @@ Wrinkles
-- checkThLocalName.
checkThLocalId :: Id -> TcM ()
checkThLocalId id
- = do { mb_local_use <- getStageAndBindLevel (idName id)
+ = do { mb_local_use <- getCurrentAndBindLevel (idName id)
; case mb_local_use of
- Just (top_lvl, bind_lvl, use_stage)
- | thLevel use_stage `Set.notMember` bind_lvl
+ Just (top_lvl, bind_lvl, use_lvl)
+ | thLevelIndex use_lvl `Set.notMember` bind_lvl
-> do
dflags <- getDynFlags
- checkCrossStageLifting dflags top_lvl id use_stage
+ checkCrossLevelLifting dflags top_lvl id use_lvl
_ -> return () -- Not a locally-bound thing, or
-- no cross-stage link
}
--------------------------------------
-checkCrossStageLifting :: DynFlags -> TopLevelFlag -> Id -> ThStage -> TcM ()
+checkCrossLevelLifting :: DynFlags -> TopLevelFlag -> Id -> ThLevel -> TcM ()
-- If we are inside typed brackets, and (use_lvl > bind_lvl)
-- we must check whether there's a cross-stage lift to do
-- Examples \x -> [|| x ||]
-- [|| map ||]
--
--- This is similar to checkCrossStageLifting in GHC.Rename.Splice, but
+-- This is similar to checkCrossLevelLifting in GHC.Rename.Splice, but
-- this code is applied to *typed* brackets.
-checkCrossStageLifting dflags top_lvl id (Brack _ (TcPending ps_var lie_var q))
+checkCrossLevelLifting dflags top_lvl id (Brack _ (TcPending ps_var lie_var q))
| isTopLevel top_lvl
, xopt LangExt.ImplicitStagePersistence dflags
= when (isExternalName id_name) (keepAlive id_name)
@@ -1146,7 +1146,7 @@ checkCrossStageLifting dflags top_lvl id (Brack _ (TcPending ps_var lie_var q))
where
id_name = idName id
-checkCrossStageLifting _ _ _ _ = return ()
+checkCrossLevelLifting _ _ _ _ = return ()
{-
Note [Lifting strings]
@@ -1181,7 +1181,7 @@ them at level 2 or 0.
The level which a name is availble at is stored in the 'GRE', in the normal
GlobalRdrEnv. The function `greLevels` returns the levels which a specific GRE
is imported at. The level information for a 'Name' is computed by `getStageAndBindLevel`.
-The level validity is checked by `checkCrossStageLifting`.
+The level validity is checked by `checkCrossLevelLifting`.
Instances are checked by `checkWellStagedDFun`, which computes the level an
instance by calling `checkWellStagedInstanceWhat`, which sees what is available at by looking at the module graph.
@@ -1189,7 +1189,7 @@ instance by calling `checkWellStagedInstanceWhat`, which sees what is available
That's it for the main implementation of the feature, and the rest is modifications
to the driver parts of the code to use this information. For example, in downsweep,
we only enable code generation for modules needed at the runtime stage.
-See Note [ExplicitLevelImports and -fno-code].
+See Note [-fno-code mode].
-}
=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -173,8 +173,8 @@ import GHC.Rename.Doc (rnHsDoc)
{-
Note [Template Haskell state diagram]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Here are the ThStages, s, their corresponding level numbers
-(the result of (thLevel s)), and their state transitions.
+Here are the ThLevels, their corresponding level numbers
+(the result of (thLevelIndex s)), and their state transitions.
The top level of the program is stage Comp:
Start here
@@ -447,7 +447,7 @@ without having to walk over the untyped bracket code. Our example
RENAMER (rnUntypedBracket):
-* Set the ThStage to (Brack s (RnPendingUntyped ps_var))
+* Set the ThLevel to (Brack s (RnPendingUntyped ps_var))
* Rename the body
@@ -557,7 +557,7 @@ RENAMER (rnTypedSplice): the renamer adds a SplicePointName, spn:
TYPECHECKER (tcTypedBracket):
-* Set the ThStage to (Brack s (TcPending ps_var lie_var))
+* Set the ThLevel to (Brack s (TcPending ps_var lie_var))
* Typecheck the body, and keep the elaborated result (despite never using it!)
@@ -669,7 +669,7 @@ runAnnotation :: CoreAnnTarget -> LHsExpr GhcRn -> TcM Annotation
-- See Note [How brackets and nested splices are handled]
tcTypedBracket rn_expr expr res_ty
= addErrCtxt (TypedTHBracketCtxt expr) $
- do { cur_stage <- getStage
+ do { cur_lvl <- getThLevel
; ps_ref <- newMutVar []
; lie_var <- getConstraintVar -- Any constraints arising from nested splices
-- should get thrown into the constraint set
@@ -686,7 +686,7 @@ tcTypedBracket rn_expr expr res_ty
-- The typechecked expression won't be used, so we just discard it
-- (See Note [The life cycle of a TH quotation] in GHC.Hs.Expr)
-- We'll typecheck it again when we splice it in somewhere
- ; (tc_expr, expr_ty) <- setStage (Brack cur_stage (TcPending ps_ref lie_var wrapper)) $
+ ; (tc_expr, expr_ty) <- setThLevel (Brack cur_lvl (TcPending ps_ref lie_var wrapper)) $
tcScalingUsage ManyTy $
-- Scale by Many, TH lifting is currently nonlinear (#18465)
tcInferRhoNC expr
@@ -835,8 +835,8 @@ getUntypedSpliceBody (HsUntypedSpliceNested {})
tcTypedSplice splice_name expr res_ty
= addErrCtxt (TypedSpliceCtxt (Just splice_name) expr) $
setSrcSpan (getLocA expr) $ do
- { stage <- getStage
- ; case stage of
+ { lvl <- getThLevel
+ ; case lvl of
Splice {} -> tcTopSplice expr res_ty
Brack pop_stage pend -> tcNestedSplice pop_stage pend splice_name expr res_ty
RunSplice _ ->
@@ -889,7 +889,7 @@ tcTopSpliceExpr isTypedSplice tc_action
= checkNoErrs $ -- checkNoErrs: must not try to run the thing
-- if the type checker fails!
- setStage (Splice isTypedSplice Comp) $
+ setThLevel (Splice isTypedSplice Comp) $
do { -- Typecheck the expression
(mb_expr', wanted) <- tryCaptureConstraints tc_action
-- If tc_action fails (perhaps because of insoluble constraints)
@@ -904,7 +904,7 @@ tcTopSpliceExpr isTypedSplice tc_action
Just expr' -> return $ mkHsDictLet (EvBinds const_binds) expr' }
------------------
-tcNestedSplice :: ThStage -> PendingStuff -> Name
+tcNestedSplice :: ThLevel -> PendingStuff -> Name
-> LHsExpr GhcRn -> ExpRhoType -> TcM (HsExpr GhcTc)
-- See Note [How brackets and nested splices are handled]
-- A splice inside brackets
@@ -912,7 +912,7 @@ tcNestedSplice pop_stage (TcPending ps_var lie_var q@(QuoteWrapper _ m_var)) spl
= do { res_ty <- expTypeToType res_ty
; let rep = getRuntimeRep res_ty
; meta_exp_ty <- tcTExpTy m_var res_ty
- ; expr' <- setStage pop_stage $
+ ; expr' <- setThLevel pop_stage $
setConstraintVar lie_var $
tcCheckMonoExpr expr meta_exp_ty
; untype_code <- tcLookupId unTypeCodeName
@@ -940,7 +940,7 @@ runTopSplice (DelayedSplice lcl_env orig_expr res_ty q_expr)
-- See Note [Collecting modFinalizers in typed splices].
; modfinalizers_ref <- newTcRef []
-- Run the expression
- ; expr2 <- setStage (RunSplice modfinalizers_ref) $
+ ; expr2 <- setThLevel (RunSplice modfinalizers_ref) $
runMetaE zonked_q_expr
; mod_finalizers <- readTcRef modfinalizers_ref
; addModFinalizersWithLclEnv $ ThModFinalizers mod_finalizers
@@ -1651,15 +1651,15 @@ lookupThInstName th_type = do
-- | Adds a mod finalizer reference to the local environment.
addModFinalizerRef :: ForeignRef (TH.Q ()) -> TcM ()
addModFinalizerRef finRef = do
- th_stage <- getStage
- case th_stage of
+ th_lvl <- getThLevel
+ case th_lvl of
RunSplice th_modfinalizers_var -> updTcRef th_modfinalizers_var (finRef :)
-- This case happens only if a splice is executed and the caller does
- -- not set the 'ThStage' to 'RunSplice' to collect finalizers.
+ -- not set the 'ThLevel' to 'RunSplice' to collect finalizers.
-- See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice.
_ ->
pprPanic "addModFinalizer was called when no finalizers were collected"
- (ppr th_stage)
+ (ppr th_lvl)
-- | Releases the external interpreter state.
finishTH :: TcM ()
=====================================
compiler/GHC/Tc/Solver/Dict.hs
=====================================
@@ -904,7 +904,7 @@ checkInstanceOK :: CtLoc -> InstanceWhat -> TcPredType -> TcS CtLoc
-- Returns the CtLoc to used for sub-goals
-- Probably also want to call checkReductionDepth
checkInstanceOK loc what pred
- = do { checkWellStagedDFun loc what pred
+ = do { checkWellLevelledDFun loc what pred
; return deeper_loc }
where
deeper_loc = zap_origin (bumpCtLocDepth loc)
=====================================
compiler/GHC/Tc/Solver/Monad.hs
=====================================
@@ -125,7 +125,7 @@ module GHC.Tc.Solver.Monad (
-- Misc
getDefaultInfo, getDynFlags, getGlobalRdrEnvTcS,
matchFam, matchFamTcM,
- checkWellStagedDFun,
+ checkWellLevelledDFun,
pprEq,
-- Enforcing invariants for type equalities
@@ -1598,48 +1598,46 @@ recordUsedGREs gres
-- Various smaller utilities [TODO, maybe will be absorbed in the instance matcher]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-checkWellStagedDFun :: CtLoc -> InstanceWhat -> PredType -> TcS ()
+checkWellLevelledDFun :: CtLoc -> InstanceWhat -> PredType -> TcS ()
-- Check that we do not try to use an instance before it is available. E.g.
-- instance Eq T where ...
-- f x = $( ... (\(p::T) -> p == p)... )
-- Here we can't use the equality function from the instance in the splice
-checkWellStagedDFun loc what pred
+checkWellLevelledDFun loc what pred
= do
- mbind_lvl <- checkWellStagedInstanceWhat what
- --env <- getLclEnv
- --use_lvl <- thLevel <$> (wrapTcS $ TcM.getStage)
+ mbind_lvl <- checkWellLevelledInstanceWhat what
case mbind_lvl of
Just (bind_lvl, is_local) ->
wrapTcS $ TcM.setCtLocM loc $ do
- { use_stage <- TcM.getStage
+ { use_lvl <- thLevelIndex <$> TcM.getThLevel
; dflags <- getDynFlags
- ; checkCrossStageClass dflags (StageCheckInstance what pred) bind_lvl (thLevel use_stage) is_local }
+ ; checkCrossLevelClass dflags (LevelCheckInstance what pred) bind_lvl use_lvl is_local }
-- If no level information is returned for an InstanceWhat, then it's safe to use
-- at any level.
Nothing -> return ()
--- TODO: Unify this with checkCrossStageLifting function
-checkCrossStageClass :: DynFlags -> StageCheckReason -> Set.Set ThLevel -> ThLevel
+-- TODO: Unify this with checkCrossLevelLifting function
+checkCrossLevelClass :: DynFlags -> LevelCheckReason -> Set.Set ThLevelIndex -> ThLevelIndex
-> Bool -> TcM ()
-checkCrossStageClass dflags reason bind_lvl use_lvl is_local
- -- If the Id is imported, ie global, then allow with PathCrossStagedPersist
+checkCrossLevelClass dflags reason bind_lvl use_lvl_idx is_local
+ -- If the Id is imported, ie global, then allow with ImplicitStagePersistence
| not is_local
, xopt LangExt.ImplicitStagePersistence dflags
= return ()
- | use_lvl `Set.member` bind_lvl = return ()
+ | use_lvl_idx `Set.member` bind_lvl = return ()
-- With path CSP, using later than bound is fine
| xopt LangExt.ImplicitStagePersistence dflags
- , any (use_lvl >=) bind_lvl = return ()
- | otherwise = TcM.failWithTc (TcRnBadlyLevelled reason bind_lvl use_lvl)
+ , any (use_lvl_idx >=) bind_lvl = return ()
+ | otherwise = TcM.failWithTc (TcRnBadlyLevelled reason bind_lvl use_lvl_idx)
-- | Returns the ThLevel of evidence for the solved constraint (if it has evidence)
--- See Note [Well-staged instance evidence]
-checkWellStagedInstanceWhat :: InstanceWhat -> TcS (Maybe (Set.Set ThLevel, Bool))
-checkWellStagedInstanceWhat what
+-- See Note [Well-levelled instance evidence]
+checkWellLevelledInstanceWhat :: InstanceWhat -> TcS (Maybe (Set.Set ThLevelIndex, Bool))
+checkWellLevelledInstanceWhat what
| TopLevInstance { iw_dfun_id = dfun_id } <- what
= do
-- MP: I am not sure if we have to only do this check for orphan instances.
@@ -1658,25 +1656,25 @@ checkWellStagedInstanceWhat what
instance_key = if moduleUnitId name_module `Set.member` hsc_all_home_unit_ids hsc_env
then (mkKey NormalLevel name_module)
else Right (moduleUnitId name_module)
- let lvls = [ -1 | splice_lvl instance_key]
- ++ [ 0 | normal_lvl instance_key]
- ++ [ 1 | quote_lvl instance_key]
+ let lvls = [ spliceLevelIndex | splice_lvl instance_key]
+ ++ [ topLevelIndex | normal_lvl instance_key]
+ ++ [ quoteLevelIndex | quote_lvl instance_key]
if isLocalId dfun_id
- then return $ Just ( (Set.singleton topLevel, True) )
+ then return $ Just ( (Set.singleton topLevelIndex, True) )
else return $ Just ( Set.fromList lvls, False )
| BuiltinTypeableInstance tc <- what
= do
cur_mod <- extractModule <$> getGblEnv
return $ Just (if nameIsLocalOrFrom cur_mod (tyConName tc)
- then (Set.singleton topLevel, True)
+ then (Set.singleton topLevelIndex, True)
-- TODO, not correct, needs similar checks to normal instances
- else (Set.fromList [(-1), topLevel], False))
+ else (Set.fromList [spliceLevelIndex, topLevelIndex], False))
| otherwise = return Nothing
{-
-Note [Well-staged instance evidence]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Note [Well-levelled instance evidence]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Evidence for instances must obey the same level restrictions as normal bindings.
In particular, it is forbidden to use an instance in a top-level splice in the
@@ -1716,12 +1714,12 @@ Main.hs:12:14: error:
Solving a `Typeable (T t1 ...tn)` constraint generates code that relies on
`$tcT`, the `TypeRep` for `T`; and we must check that this reference to `$tcT`
-is well levelled. It's easy to know the stage of `$tcT`: for imported TyCons it
+is well levelled. It's easy to know the level of `$tcT`: for imported TyCons it
will be the level of the imported TyCon Name, and for local TyCons it will be `toplevel`.
Therefore the `InstanceWhat` type had to be extended with
a special case for `Typeable`, which recorded the TyCon the evidence was for and
-could them be used to check that we were not attempting to evidence in a stage incorrect
+could them be used to check that we were not attempting to evidence in a level incorrect
manner.
-}
=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -418,8 +418,8 @@ tcInstDeclsDeriv
-> [LDerivDecl GhcRn]
-> TcM (TcGblEnv, [InstInfo GhcRn], HsValBinds GhcRn)
tcInstDeclsDeriv deriv_infos derivds
- = do th_stage <- getStage -- See Note [Deriving inside TH brackets]
- if isBrackStage th_stage
+ = do th_lvl <- getThLevel -- See Note [Deriving inside TH brackets]
+ if isBrackLevel th_lvl
then do { gbl_env <- getGblEnv
; return (gbl_env, bagToList emptyBag, emptyValBindsOut) }
else do { (tcg_env, info_bag, valbinds) <- tcDeriving deriv_infos derivds
=====================================
compiler/GHC/Tc/Types.hs
=====================================
@@ -59,9 +59,15 @@ module GHC.Tc.Types(
CompleteMatch, CompleteMatches,
-- Template Haskell
- ThStage(..), SpliceType(..), SpliceOrBracket(..), PendingStuff(..),
- topStage, topAnnStage, topSpliceStage,
- ThLevel, topLevel,thLevel,
+ ThLevel(..), SpliceType(..), SpliceOrBracket(..), PendingStuff(..),
+ topLevel, topAnnLevel, topSpliceLevel,
+ ThLevelIndex,
+ topLevelIndex,
+ spliceLevelIndex,
+ quoteLevelIndex,
+
+ thLevelIndex,
+
ForeignSrcLang(..), THDocs, DocLoc(..),
ThBindEnv,
=====================================
compiler/GHC/Tc/Types/LclEnv.hs
=====================================
@@ -11,13 +11,13 @@ module GHC.Tc.Types.LclEnv (
, getLclEnvLoc
, getLclEnvRdrEnv
, getLclEnvTcLevel
- , getLclEnvThStage
+ , getLclEnvThLevel
, setLclEnvTcLevel
, setLclEnvLoc
, setLclEnvRdrEnv
, setLclEnvBinderStack
, setLclEnvErrCtxt
- , setLclEnvThStage
+ , setLclEnvThLevel
, setLclEnvTypeEnv
, modifyLclEnvTcLevel
@@ -108,7 +108,7 @@ data TcLclCtxt
-- we can look up record field names
- tcl_th_ctxt :: ThStage, -- Template Haskell context
+ tcl_th_ctxt :: ThLevel, -- Template Haskell context
tcl_th_bndrs :: ThBindEnv, -- and binder info
-- The ThBindEnv records the TH binding level of in-scope Names
-- defined in this module (not imported)
@@ -121,11 +121,11 @@ data TcLclCtxt
-- Ids and TyVars defined in this module
}
-getLclEnvThStage :: TcLclEnv -> ThStage
-getLclEnvThStage = tcl_th_ctxt . tcl_lcl_ctxt
+getLclEnvThLevel :: TcLclEnv -> ThLevel
+getLclEnvThLevel = tcl_th_ctxt . tcl_lcl_ctxt
-setLclEnvThStage :: ThStage -> TcLclEnv -> TcLclEnv
-setLclEnvThStage s = modifyLclCtxt (\env -> env { tcl_th_ctxt = s })
+setLclEnvThLevel :: ThLevel -> TcLclEnv -> TcLclEnv
+setLclEnvThLevel l = modifyLclCtxt (\env -> env { tcl_th_ctxt = l })
getLclEnvThBndrs :: TcLclEnv -> ThBindEnv
getLclEnvThBndrs = tcl_th_bndrs . tcl_lcl_ctxt
@@ -187,7 +187,7 @@ modifyLclCtxt upd env =
type TcTypeEnv = NameEnv TcTyThing
-type ThBindEnv = NameEnv (TopLevelFlag, ThLevel)
+type ThBindEnv = NameEnv (TopLevelFlag, ThLevelIndex)
-- Domain = all Ids bound in this module (ie not imported)
-- The TopLevelFlag tells if the binding is syntactically top level.
-- We need to know this, because the cross-stage persistence story allows
=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -1533,7 +1533,7 @@ data InstanceWhat -- How did we solve this constraint?
-- See GHC.Tc.Solver.InertSet Note [Solved dictionaries]
| BuiltinTypeableInstance TyCon -- Built-in solver for Typeable (T t1 .. tn)
- -- See Note [Well-staged instance evidence]
+ -- See Note [Well-levelled instance evidence]
| BuiltinInstance -- Built-in solver for (C t1 .. tn) where C is
-- KnownNat, .. etc (classes with no top-level evidence)
=====================================
compiler/GHC/Tc/Types/TH.hs
=====================================
@@ -1,14 +1,16 @@
module GHC.Tc.Types.TH (
SpliceType(..)
, SpliceOrBracket(..)
- , ThStage(..)
+ , ThLevel(..)
, PendingStuff(..)
- , ThLevel
+ , ThLevelIndex
, topLevel
- , topStage
- , topAnnStage
- , topSpliceStage
- , thLevel
+ , topAnnLevel
+ , topSpliceLevel
+ , thLevelIndex
+ , topLevelIndex
+ , spliceLevelIndex
+ , quoteLevelIndex
) where
import GHCi.RemoteTypes
@@ -27,12 +29,12 @@ import GHC.Hs.Expr ( PendingTcSplice, PendingRnSplice )
data SpliceType = Typed | Untyped
data SpliceOrBracket = IsSplice | IsBracket
-data ThStage -- See Note [Template Haskell state diagram]
+data ThLevel -- See Note [Template Haskell state diagram]
-- and Note [Template Haskell levels] in GHC.Tc.Gen.Splice
-- Start at: Comp
-- At bracket: wrap current stage in Brack
-- At splice: wrap current stage in Splice
- = Splice SpliceType ThStage -- Inside a splice
+ = Splice SpliceType ThLevel -- Inside a splice
| RunSplice (TcRef [ForeignRef (TH.Q ())])
-- Set when running a splice, i.e. NOT when renaming or typechecking the
@@ -53,7 +55,7 @@ data ThStage -- See Note [Template Haskell state diagram]
-- Binding level = 0
| Brack -- Inside brackets
- ThStage -- Enclosing stage
+ ThLevel -- Enclosing level
PendingStuff
data PendingStuff
@@ -73,35 +75,51 @@ data PendingStuff
-- `lift`.
-topStage, topAnnStage, topSpliceStage :: ThStage
-topStage = Comp
-topAnnStage = Splice Untyped Comp
-topSpliceStage = Splice Untyped Comp
+topLevel, topAnnLevel, topSpliceLevel :: ThLevel
+topLevel = Comp
+topAnnLevel = Splice Untyped Comp
+topSpliceLevel = Splice Untyped Comp
-instance Outputable ThStage where
+instance Outputable ThLevel where
ppr (Splice _ s) = text "Splice" <> parens (ppr s)
ppr (RunSplice _) = text "RunSplice"
ppr Comp = text "Comp"
ppr (Brack s _) = text "Brack" <> parens (ppr s)
-type ThLevel = Int
+-- | The integer which represents the level
+newtype ThLevelIndex = ThLevelIndex Int deriving (Eq, Ord)
-- NB: see Note [Template Haskell levels] in GHC.Tc.Gen.Splice
-- Incremented when going inside a bracket,
-- decremented when going inside a splice
-topLevel :: ThLevel
-topLevel = thLevel Comp
+instance Outputable ThLevelIndex where
+ ppr (ThLevelIndex i) = int i
-thLevel :: ThStage -> ThLevel
-thLevel (Splice _ s) = thLevel s - 1
-thLevel Comp = 0
-thLevel (Brack s _) = thLevel s + 1
-thLevel (RunSplice _) = thLevel (Splice Untyped Comp) -- previously: panic "thLevel: called when running a splice"
+incThLevelIndex :: ThLevelIndex -> ThLevelIndex
+incThLevelIndex (ThLevelIndex i) = ThLevelIndex (i + 1)
+
+decThLevelIndex :: ThLevelIndex -> ThLevelIndex
+decThLevelIndex (ThLevelIndex i) = ThLevelIndex (i - 1)
+
+topLevelIndex :: ThLevelIndex
+topLevelIndex = thLevelIndex Comp
+
+spliceLevelIndex :: ThLevelIndex
+spliceLevelIndex = thLevelIndex (Splice Untyped Comp)
+
+quoteLevelIndex :: ThLevelIndex
+quoteLevelIndex = thLevelIndex (Brack Comp RnPendingTyped)
+
+thLevelIndex :: ThLevel -> ThLevelIndex
+thLevelIndex (Splice _ s) = decThLevelIndex (thLevelIndex s)
+thLevelIndex Comp = ThLevelIndex 0
+thLevelIndex (Brack s _) = incThLevelIndex (thLevelIndex s)
+thLevelIndex (RunSplice _) = thLevelIndex (Splice Untyped Comp) -- previously: panic "thLevel: called when running a splice"
-- See Note [RunSplice ThLevel].
{- Note [RunSplice ThLevel]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The 'RunSplice' stage is set when executing a splice, and only when running a
+The 'RunSplice' level is set when executing a splice, and only when running a
splice. In particular it is not set when the splice is renamed or typechecked.
However, this is not true. `reifyInstances` for example does rename the given type,
=====================================
compiler/GHC/Tc/Utils/Concrete.hs
=====================================
@@ -670,7 +670,7 @@ checkFRR_with :: HasDebugCallStack
-- ^ Returns @(co, frr_ty)@ with @co :: ty ~# frr_ty@
-- and @frr_@ty has a fixed 'RuntimeRep'.
checkFRR_with check_kind frr_ctxt ty
- = do { th_stage <- getStage
+ = do { th_lvl <- getThLevel
; if
-- Shortcut: check for 'Type' and 'UnliftedType' type synonyms.
| TyConApp tc [] <- ki
@@ -678,7 +678,7 @@ checkFRR_with check_kind frr_ctxt ty
-> return refl
-- See [Wrinkle: Typed Template Haskell] in Note [hasFixedRuntimeRep].
- | Brack _ (TcPending {}) <- th_stage
+ | Brack _ (TcPending {}) <- th_lvl
-> return refl
-- Otherwise: ensure that the kind 'ki' of 'ty' is concrete.
=====================================
compiler/GHC/Tc/Utils/Env.hs
=====================================
@@ -60,9 +60,9 @@ module GHC.Tc.Utils.Env(
tcGetDefaultTys,
-- Template Haskell stuff
- StageCheckReason(..),
- tcMetaTy, thLevel,
- isBrackStage,
+ LevelCheckReason(..),
+ tcMetaTy, thLevelIndex,
+ isBrackLevel,
-- New Ids
newDFunName,
@@ -521,9 +521,8 @@ tcExtendTyConEnv tycons thing_inside
-- See GHC ticket #17820 .
tcTyThBinders :: [TyThing] -> TcM ThBindEnv
tcTyThBinders implicit_things = do
- stage <- getStage
- let th_lvl = thLevel stage
- th_bndrs = mkNameEnv
+ th_lvl <- thLevelIndex <$> getThLevel
+ let th_bndrs = mkNameEnv
[ ( n , (TopLevel, th_lvl) ) | n <- names ]
return th_bndrs
where
@@ -759,7 +758,7 @@ tc_extend_local_env top_lvl extra_env thing_inside
= do { traceTc "tc_extend_local_env" (ppr extra_env)
; updLclCtxt upd_lcl_env thing_inside }
where
- upd_lcl_env env0@(TcLclCtxt { tcl_th_ctxt = stage
+ upd_lcl_env env0@(TcLclCtxt { tcl_th_ctxt = th_lvl
, tcl_rdr = rdr_env
, tcl_th_bndrs = th_bndrs
, tcl_env = lcl_type_env })
@@ -776,7 +775,7 @@ tc_extend_local_env top_lvl extra_env thing_inside
-- Template Haskell staging env simultaneously. Reason for extending
-- LocalRdrEnv: after running a TH splice we need to do renaming.
where
- thlvl = (top_lvl, thLevel stage)
+ thlvl = (top_lvl, thLevelIndex th_lvl)
tcExtendLocalTypeEnv :: [(Name, TcTyThing)] -> TcLclCtxt -> TcLclCtxt
@@ -931,9 +930,9 @@ tcMetaTy tc_name = do
t <- tcLookupTyCon tc_name
return (mkTyConTy t)
-isBrackStage :: ThStage -> Bool
-isBrackStage (Brack {}) = True
-isBrackStage _other = False
+isBrackLevel :: ThLevel -> Bool
+isBrackLevel (Brack {}) = True
+isBrackLevel _other = False
{-
************************************************************************
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -117,7 +117,7 @@ module GHC.Tc.Utils.Monad(
-- * Template Haskell context
recordThUse, recordThNeededRuntimeDeps,
- keepAlive, getStage, getStageAndBindLevel, setStage,
+ keepAlive, getThLevel, getCurrentAndBindLevel, setThLevel,
addModFinalizersWithLclEnv,
-- * Safe Haskell context
@@ -399,7 +399,7 @@ initTcWithGbl hsc_env gbl_env loc do_this
tcl_in_gen_code = False,
tcl_ctxt = [],
tcl_rdr = emptyLocalRdrEnv,
- tcl_th_ctxt = topStage,
+ tcl_th_ctxt = topLevel,
tcl_th_bndrs = emptyNameEnv,
tcl_arrow_ctxt = NoArrowCtxt,
tcl_env = emptyNameEnv,
@@ -2110,11 +2110,11 @@ keepAlive name
; traceRn "keep alive" (ppr name)
; updTcRef (tcg_keep env) (`extendNameSet` name) }
-getStage :: TcM ThStage
-getStage = do { env <- getLclEnv; return (getLclEnvThStage env) }
+getThLevel :: TcM ThLevel
+getThLevel = do { env <- getLclEnv; return (getLclEnvThLevel env) }
-getStageAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, Set.Set ThLevel, ThStage))
-getStageAndBindLevel name
+getCurrentAndBindLevel :: Name -> TcRn (Maybe (TopLevelFlag, Set.Set ThLevelIndex, ThLevel))
+getCurrentAndBindLevel name
= do { env <- getLclEnv;
; case lookupNameEnv (getLclEnvThBndrs env) name of
Nothing -> do
@@ -2128,10 +2128,10 @@ getStageAndBindLevel name
--env <- getGlobalRdrEnv
--pprTrace "NO_LVLS" (ppr name) (return Nothing)
return Nothing
- else return (Just (TopLevel, lvls, getLclEnvThStage env))
- Just (top_lvl, bind_lvl) -> return (Just (top_lvl, Set.singleton bind_lvl, getLclEnvThStage env)) }
+ else return (Just (TopLevel, lvls, getLclEnvThLevel env))
+ Just (top_lvl, bind_lvl) -> return (Just (top_lvl, Set.singleton bind_lvl, getLclEnvThLevel env)) }
-getExternalBindLvl :: Name -> TcRn (Set.Set ThLevel)
+getExternalBindLvl :: Name -> TcRn (Set.Set ThLevelIndex)
getExternalBindLvl name = do
env <- getGlobalRdrEnv
mod <- getModule
@@ -2139,16 +2139,16 @@ getExternalBindLvl name = do
Just gre -> return $ (Set.map convert_lvl (greLevels gre))
Nothing ->
if nameIsLocalOrFrom mod name
- then return $ Set.singleton topLevel
+ then return $ Set.singleton topLevelIndex
-- else pprTrace "NO LVLS" (ppr name) (return Set.empty) -- pprPanic "getExternalBindLvl" (ppr env $$ ppr name $$ ppr (nameSrcSpan name))
else return Set.empty
where
- convert_lvl NormalLevel = thLevel topStage
- convert_lvl SpliceLevel = thLevel topSpliceStage
- convert_lvl QuoteLevel = thLevel (Brack topStage undefined)
+ convert_lvl NormalLevel = topLevelIndex
+ convert_lvl SpliceLevel = spliceLevelIndex
+ convert_lvl QuoteLevel = quoteLevelIndex
-setStage :: ThStage -> TcM a -> TcRn a
-setStage s = updLclEnv (setLclEnvThStage s)
+setThLevel :: ThLevel -> TcM a -> TcRn a
+setThLevel l = updLclEnv (setLclEnvThLevel l)
-- | Adds the given modFinalizers to the global environment and set them to use
-- the current local environment.
=====================================
compiler/GHC/Tc/Utils/TcMType.hs
=====================================
@@ -458,11 +458,11 @@ newInferExpType = new_inferExpType Nothing
newInferExpTypeFRR :: FixedRuntimeRepContext -> TcM ExpTypeFRR
newInferExpTypeFRR frr_orig
- = do { th_stage <- getStage
+ = do { th_lvl <- getThLevel
; if
-- See [Wrinkle: Typed Template Haskell]
-- in Note [hasFixedRuntimeRep] in GHC.Tc.Utils.Concrete.
- | Brack _ (TcPending {}) <- th_stage
+ | Brack _ (TcPending {}) <- th_lvl
-> new_inferExpType Nothing
| otherwise
@@ -800,11 +800,11 @@ newConcreteTyVar :: HasDebugCallStack => ConcreteTvOrigin
-> FastString -> TcKind -> TcM TcTyVar
newConcreteTyVar reason fs kind
= assertPpr (isConcreteType kind) assert_msg $
- do { th_stage <- getStage
+ do { th_lvl <- getThLevel
; if
-- See [Wrinkle: Typed Template Haskell]
-- in Note [hasFixedRuntimeRep] in GHC.Tc.Utils.Concrete.
- | Brack _ (TcPending {}) <- th_stage
+ | Brack _ (TcPending {}) <- th_lvl
-> newNamedAnonMetaTyVar fs TauTv kind
| otherwise
@@ -986,8 +986,8 @@ newOpenFlexiTyVar
-- in GHC.Tc.Utils.Concrete.
newOpenFlexiFRRTyVar :: FixedRuntimeRepContext -> TcM TcTyVar
newOpenFlexiFRRTyVar frr_ctxt
- = do { th_stage <- getStage
- ; case th_stage of
+ = do { th_lvl <- getThLevel
+ ; case th_lvl of
{ Brack _ (TcPending {}) -- See [Wrinkle: Typed Template Haskell]
-> newOpenFlexiTyVar -- in Note [hasFixedRuntimeRep] in GHC.Tc.Utils.Concrete.
; _ ->
@@ -1040,11 +1040,11 @@ newMetaTyVarX = new_meta_tv_x TauTv
-- | Like 'newMetaTyVarX', but for concrete type variables.
newConcreteTyVarX :: ConcreteTvOrigin -> Subst -> TyVar -> TcM (Subst, TcTyVar)
newConcreteTyVarX conc subst tv
- = do { th_stage <- getStage
+ = do { th_lvl <- getThLevel
; if
-- See [Wrinkle: Typed Template Haskell]
-- in Note [hasFixedRuntimeRep] in GHC.Tc.Utils.Concrete.
- | Brack _ (TcPending {}) <- th_stage
+ | Brack _ (TcPending {}) <- th_lvl
-> new_meta_tv_x TauTv subst tv
| otherwise
-> new_meta_tv_x (ConcreteTv conc) subst tv }
=====================================
compiler/GHC/Types/Error/Codes.hs
=====================================
@@ -967,7 +967,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "NestedTHBrackets" = 59185
GhcDiagnosticCode "AddTopDeclsUnexpectedDeclarationSplice" = 17599
GhcDiagnosticCode "BadImplicitSplice" = 25277
- GhcDiagnosticCode "QuotedNameWrongStage" = 57695
+ GhcDiagnosticCode "QuotedNameWrongStage" = Outdated 57695
GhcDiagnosticCode "IllegalStaticFormInSplice" = 12219
-- Zonker messages
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49dd72380ae886224fb16671699a58…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/49dd72380ae886224fb16671699a58…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/splice-imports-2025] 5 commits: Documentation
by Matthew Pickering (@mpickering) 17 Apr '25
by Matthew Pickering (@mpickering) 17 Apr '25
17 Apr '25
Matthew Pickering pushed to branch wip/splice-imports-2025 at Glasgow Haskell Compiler / GHC
Commits:
9c357ba0 by Matthew Pickering at 2025-04-17T11:14:14+01:00
Documentation
- - - - -
ddbba2de by Matthew Pickering at 2025-04-17T11:55:35+01:00
wip, fix level numbers
- - - - -
cf9d37cd by Matthew Pickering at 2025-04-17T14:01:44+01:00
fixes
- - - - -
680d0f57 by Matthew Pickering at 2025-04-17T14:36:39+01:00
Levels rather than stages
- - - - -
49dd7238 by Matthew Pickering at 2025-04-17T14:42:24+01:00
Delete dead code (I tested the tests worked)
- - - - -
81 changed files:
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/ImpExp.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Splice.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/TH.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Unit/Module/Deps.hs
- compiler/GHC/Unit/Module/Graph.hs
- compiler/GHC/Unit/Module/ModSummary.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/Language/Haskell/Syntax/ImpExp.hs
- − compiler/Language/Haskell/Syntax/ImpExp/ImportLevel.hs
- compiler/ghc.cabal.in
- docs/users_guide/exts/template_haskell.rst
- docs/users_guide/phases.rst
- docs/users_guide/using-warnings.rst
- testsuite/tests/annotations/should_fail/annfail03.stderr
- testsuite/tests/annotations/should_fail/annfail04.stderr
- testsuite/tests/annotations/should_fail/annfail06.stderr
- testsuite/tests/annotations/should_fail/annfail09.stderr
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/module/mod185.stderr
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/DumpSemis.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/parser/should_compile/T14189.stderr
- testsuite/tests/quasiquotation/qq001/qq001.stderr
- testsuite/tests/quasiquotation/qq002/qq002.stderr
- testsuite/tests/quasiquotation/qq003/qq003.stderr
- testsuite/tests/quasiquotation/qq004/qq004.stderr
- testsuite/tests/quotes/T5721.stderr
- testsuite/tests/splice-imports/SI03.stderr
- testsuite/tests/splice-imports/SI05.stderr
- testsuite/tests/splice-imports/SI08.stderr
- testsuite/tests/splice-imports/SI08_oneshot.stderr
- testsuite/tests/splice-imports/SI14.stderr
- testsuite/tests/splice-imports/SI15.stderr
- testsuite/tests/splice-imports/SI16.stderr
- testsuite/tests/splice-imports/SI18.stderr
- testsuite/tests/splice-imports/SI20.stderr
- + testsuite/tests/splice-imports/SI25.hs
- + testsuite/tests/splice-imports/SI25.stderr
- + testsuite/tests/splice-imports/SI25Helper.hs
- + testsuite/tests/splice-imports/SI26.hs
- + testsuite/tests/splice-imports/SI27.hs
- + testsuite/tests/splice-imports/SI27.stderr
- testsuite/tests/splice-imports/all.T
- testsuite/tests/th/T16976z.stderr
- testsuite/tests/th/T17820a.stderr
- testsuite/tests/th/T17820b.stderr
- testsuite/tests/th/T17820c.stderr
- testsuite/tests/th/T17820d.stderr
- testsuite/tests/th/T17820e.stderr
- testsuite/tests/th/T21547.stderr
- testsuite/tests/th/T23829_hasty.stderr
- testsuite/tests/th/T23829_hasty_b.stderr
- testsuite/tests/th/T23829_tardy.ghc.stderr
- testsuite/tests/th/T5795.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e1422c8a8e163070028b4b064544e…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1e1422c8a8e163070028b4b064544e…
You're receiving this email because of your account on gitlab.haskell.org.
1
0