[Git][ghc/ghc][master] Initialize plugins for `:set +c` in GHCi
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a541dd83 by Chris Wendt at 2026-02-11T16:06:41-05:00 Initialize plugins for `:set +c` in GHCi Fixes #23110. - - - - - 5 changed files: - ghc/GHCi/UI/Info.hs - + testsuite/tests/plugins/T23110.hs - + testsuite/tests/plugins/T23110.script - + testsuite/tests/plugins/T23110.stdout - testsuite/tests/plugins/all.T Changes: ===================================== ghc/GHCi/UI/Info.hs ===================================== @@ -46,6 +46,8 @@ import GHC.Utils.Outputable import GHC.Types.SrcLoc import GHC.Types.Var import qualified GHC.Data.Strict as Strict +import GHC.Runtime.Loader (initializePlugins) +import Data.Containers.ListUtils (nubOrd) import GHCi.UI.Exception @@ -301,6 +303,13 @@ srcFilePath modSum = fromMaybe obj_fp src_fp getModInfo :: (GhcMonad m) => Module -> m ModInfo getModInfo m = do mod_summary <- getModSummary m + + -- Update the session plugins from the module summary + -- and initialize them (#23110). + modifySession $ hscUpdateFlags $ \dynFlags -> dynFlags + { pluginModNames = nubOrd $ pluginModNames dynFlags ++ pluginModNames (ms_hspp_opts mod_summary) } + modifySessionM (liftIO . initializePlugins) + p <- parseModule mod_summary typechecked <- typecheckModule p let allTypes = processAllTypeCheckedModule typechecked ===================================== testsuite/tests/plugins/T23110.hs ===================================== @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -fplugin=Simple.SourcePlugin #-} + +module Main where + +main :: IO () +main = return () ===================================== testsuite/tests/plugins/T23110.script ===================================== @@ -0,0 +1,3 @@ +:set +c +:load T23110.hs +-- The key thing is that plugins should be run AFTER "Collecting type info..." ===================================== testsuite/tests/plugins/T23110.stdout ===================================== @@ -0,0 +1,11 @@ +parsePlugin() +typeCheckPlugin (rn) +interfacePlugin: GHC.Internal.Tuple +interfacePlugin: GHC.Internal.Stack.Types +interfacePlugin: GHC.Internal.Exception.Context +interfacePlugin: GHC.Internal.TopHandler +typeCheckPlugin (tc) +Collecting type info for 1 module(s) ... +parsePlugin() +typeCheckPlugin (rn) +typeCheckPlugin (tc) ===================================== testsuite/tests/plugins/all.T ===================================== @@ -332,6 +332,19 @@ test('T20803b', compile_fail, ['-package-db T20803-plugin/pkg.T20803b/local.package.conf -fplugin AddErrorPlugin -package T20803-plugin ' + config.plugin_way_flags]) +# Check that we run the plugins for set +c. +# The .stdout file should contain a call to 'parsePlugin' AFTER +# the line 'Collecting type info...' +test('T23110' + , [ extra_files([ 'simple-plugin/']) + , only_ways(['ghci']) + , pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.simpleplug TOP={top}') + , extra_hc_opts('-package-db simple-plugin/pkg.simpleplug/local.package.conf') + ] + , ghci_script + , [ 'T23110.script' ] + ) + test('test-echo-in-turn', [extra_files(['echo-plugin/']), pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a541dd832c3c5ecceab91907477c5495... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a541dd832c3c5ecceab91907477c5495... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)