Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

5 changed files:

Changes:

  • ghc/GHCi/UI/Info.hs
    ... ... @@ -46,6 +46,8 @@ import GHC.Utils.Outputable
    46 46
     import           GHC.Types.SrcLoc
    
    47 47
     import           GHC.Types.Var
    
    48 48
     import qualified GHC.Data.Strict as Strict
    
    49
    +import           GHC.Runtime.Loader (initializePlugins)
    
    50
    +import           Data.Containers.ListUtils (nubOrd)
    
    49 51
     
    
    50 52
     import           GHCi.UI.Exception
    
    51 53
     
    
    ... ... @@ -301,6 +303,13 @@ srcFilePath modSum = fromMaybe obj_fp src_fp
    301 303
     getModInfo :: (GhcMonad m) => Module -> m ModInfo
    
    302 304
     getModInfo m = do
    
    303 305
         mod_summary <- getModSummary m
    
    306
    +
    
    307
    +    -- Update the session plugins from the module summary
    
    308
    +    -- and initialize them (#23110).
    
    309
    +    modifySession $ hscUpdateFlags $ \dynFlags -> dynFlags
    
    310
    +      { pluginModNames = nubOrd $ pluginModNames dynFlags ++ pluginModNames (ms_hspp_opts mod_summary) }
    
    311
    +    modifySessionM (liftIO . initializePlugins)
    
    312
    +
    
    304 313
         p <- parseModule mod_summary
    
    305 314
         typechecked <- typecheckModule p
    
    306 315
         let allTypes = processAllTypeCheckedModule typechecked
    

  • testsuite/tests/plugins/T23110.hs
    1
    +{-# OPTIONS_GHC -fplugin=Simple.SourcePlugin #-}
    
    2
    +
    
    3
    +module Main where
    
    4
    +
    
    5
    +main :: IO ()
    
    6
    +main = return ()

  • testsuite/tests/plugins/T23110.script
    1
    +:set +c
    
    2
    +:load T23110.hs
    
    3
    +-- The key thing is that plugins should be run AFTER "Collecting type info..."

  • testsuite/tests/plugins/T23110.stdout
    1
    +parsePlugin()
    
    2
    +typeCheckPlugin (rn)
    
    3
    +interfacePlugin: GHC.Internal.Tuple
    
    4
    +interfacePlugin: GHC.Internal.Stack.Types
    
    5
    +interfacePlugin: GHC.Internal.Exception.Context
    
    6
    +interfacePlugin: GHC.Internal.TopHandler
    
    7
    +typeCheckPlugin (tc)
    
    8
    +Collecting type info for 1 module(s) ... 
    
    9
    +parsePlugin()
    
    10
    +typeCheckPlugin (rn)
    
    11
    +typeCheckPlugin (tc)

  • testsuite/tests/plugins/all.T
    ... ... @@ -332,6 +332,19 @@ test('T20803b',
    332 332
          compile_fail,
    
    333 333
          ['-package-db T20803-plugin/pkg.T20803b/local.package.conf -fplugin AddErrorPlugin -package T20803-plugin ' + config.plugin_way_flags])
    
    334 334
     
    
    335
    +# Check that we run the plugins for set +c.
    
    336
    +# The .stdout file should contain a call to 'parsePlugin' AFTER
    
    337
    +# the line 'Collecting type info...'
    
    338
    +test('T23110'
    
    339
    +    , [ extra_files([ 'simple-plugin/'])
    
    340
    +      , only_ways(['ghci'])
    
    341
    +      , pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.simpleplug TOP={top}')
    
    342
    +      , extra_hc_opts('-package-db simple-plugin/pkg.simpleplug/local.package.conf')
    
    343
    +      ]
    
    344
    +    , ghci_script
    
    345
    +    , [ 'T23110.script' ]
    
    346
    +    )
    
    347
    +
    
    335 348
     test('test-echo-in-turn',
    
    336 349
          [extra_files(['echo-plugin/']),
    
    337 350
           pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')],