[Git][ghc/ghc][master] 2 commits: Add regression test for #27641
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3cc21e4c by Hannes Siebenhandl at 2026-10-01T20:22:59-04:00 Add regression test for #27641 - - - - - c35096f5 by Hannes Siebenhandl at 2026-10-01T20:23:00-04:00 Don't `:add` modules the loader will reject Only home modules can be actually added to the loader context, thus we only accept the module if it belongs to a home unit. - - - - - 6 changed files: - + changelog.d/27641 - ghc/GHCi/UI.hs - + testsuite/tests/ghci/scripts/T27641.script - + testsuite/tests/ghci/scripts/T27641.stderr - + testsuite/tests/ghci/scripts/T27641.stdout - testsuite/tests/ghci/scripts/all.T Changes: ===================================== changelog.d/27641 ===================================== @@ -0,0 +1,4 @@ +section: ghci +synopsis: Don't accept modules in `:add` that the loader will reject +issues: #27641 +mrs: !16734 ===================================== ghc/GHCi/UI.hs ===================================== @@ -180,6 +180,7 @@ import GHC.IO.Handle ( hFlushAll ) import GHC.TopHandler ( topHandler ) import qualified GHC.Unit.Module.Graph as GHC +import GHC.Unit.Home.Graph (memberHugUnit) ----------------------------------------------------------------------------- @@ -2400,7 +2401,9 @@ addModule files = do result <- liftIO $ Finder.findImportedModule hsc_env Finder.LookupUser m NoPkgQual case result of - Found _ _ -> return True + -- We could find a module from a dependency, such as `Data.List`, but we can't + -- actualy load that unless the module is located in a home unit. + Found _ m | moduleUnit m `memberHugUnit` hsc_HUG hsc_env -> return True _ -> do reportError (GhciModuleError $ GhciModuleNotFound (moduleNameString m)) return False ===================================== testsuite/tests/ghci/scripts/T27641.script ===================================== @@ -0,0 +1,3 @@ +:add Data.List +:reload +putStrLn ":add Data.List should fail and a subsequent :reload should succeed" ===================================== testsuite/tests/ghci/scripts/T27641.stderr ===================================== @@ -0,0 +1,2 @@ +<interactive>: error: [GHCi-23305] Module Data.List not found + ===================================== testsuite/tests/ghci/scripts/T27641.stdout ===================================== @@ -0,0 +1 @@ +:add Data.List should fail and a subsequent :reload should succeed ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -402,3 +402,4 @@ test('GhciPackageRename', ghci_script, ['GhciPackageRename.script']) test('T26233', normal, ghci_script, ['T26233.script']) +test('T27641', normal, ghci_script, ['T27641.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d2a26eee4c05dde46bccc83af3ea0d... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1d2a26eee4c05dde46bccc83af3ea0d... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Marge Bot (@marge-bot)