Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: bffa37b8 by Rodrigo Mesquita at 2026-06-12T10:15:58+01:00 Revert "Better specification for when to disable defaulting" This reverts commit ac878ff32e63933b1f4268c7005129ebf3b85df6. - - - - - 54d9d6cf by Rodrigo Mesquita at 2026-06-12T10:22:23+01:00 undo changes to defaulting - - - - - 2495294b by Rodrigo Mesquita at 2026-06-12T14:21:37+01:00 Use structured error representation for missing GHC.Essentials Adds test T27013e to observe error - - - - - 43c33171 by Rodrigo Mesquita at 2026-06-12T14:35:48+01:00 augment err mesg - - - - - f7b1ed81 by Rodrigo Mesquita at 2026-06-12T15:13:29+01:00 fix augment - - - - - 0c2eb2d9 by Rodrigo Mesquita at 2026-06-12T16:05:10+01:00 Improve failure error when looking up the module directly And improve flag description, noting the implicit dependency. - - - - - def6b32e by Rodrigo Mesquita at 2026-06-12T16:09:04+01:00 SCS5 isSolvedWC fixes Num needed for composition - - - - - 5bb55594 by Rodrigo Mesquita at 2026-06-12T16:10:41+01:00 fixup! Improve failure error when looking up the module directly - - - - - b561913d by Rodrigo Mesquita at 2026-06-12T16:53:37+01:00 testsuite: -frebindable-known-names forces a dependency Therefore, to compile a module with -hide-all-packages, regardless of whether or not it uses known-names, we need -frebindable-known-names to tell GHC to not add that implicit dependency. Also a test that checks the error message when we don't have that flag. - - - - - 7e9c113b by Rodrigo Mesquita at 2026-06-12T16:57:03+01:00 typo - - - - - 18 changed files: - compiler/GHC/Builtin.hs - compiler/GHC/Iface/Errors/Ppr.hs - compiler/GHC/Iface/Errors/Types.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Solver/Default.hs - compiler/GHC/Tc/Solver/Dict.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Types/Error/Codes.hs - docs/users_guide/separate_compilation.rst - testsuite/tests/cabal/T27013a/Makefile - testsuite/tests/cabal/T27013d/Makefile - + testsuite/tests/driver/T27013e/T27013e.hs - + testsuite/tests/driver/T27013e/T27013e.stderr - + testsuite/tests/driver/T27013e/all.T - + testsuite/tests/driver/T27013f/T27013f.hs - + testsuite/tests/driver/T27013f/T27013f.stderr - + testsuite/tests/driver/T27013f/all.T Changes: ===================================== compiler/GHC/Builtin.hs ===================================== @@ -372,11 +372,6 @@ Wrinkles keeps types and classes in the global type envt, but `Id`s in the local type envt. (Ids move to the global type env during zonking; see `zonkTopDecls`.) -(KN5) If we are not using -frebindable-known-names, yet GHC.Essentials is still not - in scope, then we don't add the `default Num (Integer, Double)` declaration - to the module being compiled. This relaxation makes it possible for a library - which does not use any known-key at all (namely: `composition`) to compile - successfully without a dependency on base nor ghc-internal. Note [Recipe for adding a known-occ name] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Iface/Errors/Ppr.hs ===================================== @@ -25,6 +25,7 @@ module GHC.Iface.Errors.Ppr import GHC.Prelude import GHC.Builtin( knownKeyOccName_maybe ) +import GHC.Builtin.Modules( eSSENTIALS_NAME ) import GHC.Types.Error import GHC.Types.Hint.Ppr () -- Outputable GhcHint import GHC.Types.Error.Codes @@ -67,6 +68,7 @@ interfaceErrorHints = \ case MissingKnownKey2 {} -> noHints MissingKnownKey3 {} -> noHints KnownKeyScopeError {} -> noHints + CantFindEssentials {} -> noHints missingInterfaceErrorHints :: MissingInterfaceError -> [GhcHint] missingInterfaceErrorHints = \case @@ -93,6 +95,7 @@ interfaceErrorReason (MissingKnownKey1 {}) = ErrorWithoutFlag interfaceErrorReason (MissingKnownKey2 {}) = ErrorWithoutFlag interfaceErrorReason (MissingKnownKey3 {}) = ErrorWithoutFlag interfaceErrorReason (KnownKeyScopeError {}) = ErrorWithoutFlag +interfaceErrorReason (CantFindEssentials {}) = ErrorWithoutFlag missingInterfaceErrorReason :: MissingInterfaceError -> DiagnosticReason missingInterfaceErrorReason = \ case @@ -321,6 +324,32 @@ interfaceErrorDiagnostic opts = \ case -> hang (text "Known-key entity" <+> quotes (ppr occ)) 2 (text "is ambiguous in the top-level global environment" $$ ppr gres) + CantFindEssentials err reason -> + vcat + [ vcat [ hang (text "Failed to load the known-names module" <+> quotes (ppr eSSENTIALS_NAME) <+> text "from the visible packages") + 2 (case reason of + UnknownLoadEssentialsReason -> empty + LookingForKnownOcc occ -> text "while looking for known-occ name" <+> quotes (ppr occ) + LookingForKnownKey key -> text "while looking for known-key" <+> quotes (pprKnownKey key) + LookingForEssentialsModule -> text "while trying to discover its package") + , text "Did you mean to use" <+> quotes (text "-package base") <> text "?" ] + , blankLine + , missingInterfaceErrorDiagnostic opts err + , blankLine + , case reason of + LookingForEssentialsModule + -> vcat [ text "This error was triggered while trying to discover the package of" <+> quotes (ppr eSSENTIALS_NAME) <> comma + , text "rather than when looking up any specific known-name." + , text "If you want to enforce" <+> quotes (ppr eSSENTIALS_NAME) <+> text "is not added to the module graph implicitly," + , text "you should use" <+> quotes (text "-frebindable-known-names") + ] + _ -> hang (text "To lookup known-names in scope rather than in GHC.Essentials" <> comma) + 2 (vcat [ text "use" <+> quotes (text "-frebindable-known-names") <> comma <+> text "and import" + , text "the necessary known-names definitions from" <+> quotes (text "ghc-internal") <> dot + -- Alternatively, you may want to unsafely provide your own GHC.Essentials exposing the known-names you need in scope." + ]) + ] + lookingForHerald :: InterfaceLookingFor -> SDoc lookingForHerald looking_for = case looking_for of ===================================== compiler/GHC/Iface/Errors/Types.hs ===================================== @@ -9,6 +9,7 @@ module GHC.Iface.Errors.Types ( , FindingModuleOrInterface(..) , BuildingCabalPackage(..) + , LoadEssentialsReason(..) , IfaceMessageOpts(..) @@ -70,6 +71,15 @@ data IfaceMessage -- We looked up a known-occ in the GlobalRdrEnv, -- but did not find a unique hit -- CallStack is so that we can get a backtrace + + | CantFindEssentials MissingInterfaceError LoadEssentialsReason + -- We failed to find GHC.Essentials, the module exported from base which + -- exports all the compiler known-names. The 'MissingInterfaceError' is + -- the underlying reason the module could not be found. A 'KnownKey' is + -- attached if we were looking for one when we failed to load GHC.Essentials + -- + -- Test cases: + -- tests/driver/T27013e deriving Generic data MissingInterfaceError @@ -113,3 +123,11 @@ data BuildingCabalPackage = YesBuildingCabalPackage | NoBuildingCabalPackage deriving Eq + +data LoadEssentialsReason + = LookingForKnownKey KnownKey + | LookingForKnownOcc KnownOcc + | LookingForEssentialsModule + | UnknownLoadEssentialsReason + deriving Generic + ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -73,7 +73,6 @@ import GHC.Iface.Binary import GHC.Iface.Rename import GHC.Iface.Env import GHC.Iface.Errors as Iface_Errors -import GHC.Iface.Errors.Ppr( defaultIfaceMessageOpts, missingInterfaceErrorDiagnostic ) import GHC.Tc.Errors.Types import GHC.Tc.Utils.Monad @@ -188,8 +187,12 @@ lookupKnownKeyName :: HasDebugCallStack => KnownKey -> KnownEntitySource -> IfM lcl (MaybeErr IfaceMessage Name) lookupKnownKeyName key KES_FromModule - = do { (kk_map, _) <- loadKnownKeyOccMaps - ; return $ lookupKnownKeysMap kk_map key } + = do { mb_maps <- loadKnownKeyOccMaps + ; return $ case mb_maps of + Failed (CantFindEssentials err UnknownLoadEssentialsReason) -- augment error + -> Failed (CantFindEssentials err (LookingForKnownKey key)) + Failed err -> Failed err + Succeeded (kk_map, _) -> lookupKnownKeysMap kk_map key } lookupKnownKeyName key (KES_InScope { ke_rdr_env = gbl_rdr_env }) -- Just gbl_rdr_env: we have -frebindable-known-names on, and @@ -240,10 +243,15 @@ lookupKnownOccName :: HasDebugCallStack => KnownOcc -> KnownEntitySource -> IfM lcl (MaybeErr IfaceMessage Name) lookupKnownOccName occ KES_FromModule - = do { (_, occ_map) <- loadKnownKeyOccMaps - ; case lookupOccEnv occ_map occ of - Just name -> return (Succeeded name) - Nothing -> return (Failed (MissingKnownKey3 occ)) } + = do { mb_maps <- loadKnownKeyOccMaps + ; return $ case mb_maps of + Failed (CantFindEssentials err UnknownLoadEssentialsReason) -- augment error + -> Failed (CantFindEssentials err (LookingForKnownOcc occ)) + Failed err -> Failed err + Succeeded (_, occ_map) -> + case lookupOccEnv occ_map occ of + Just name -> Succeeded name + Nothing -> Failed (MissingKnownKey3 occ) } lookupKnownOccName occ (KES_InScope { ke_rdr_env = gbl_rdr_env }) -- Just gbl_rdr_env: we have -frebindable-known-names on, and @@ -279,23 +287,29 @@ lookupKnownName kk_ns name where name_mod = nameModule name -loadKnownKeyOccMaps :: IfM lcl KnownKeyNameMaps +loadKnownKeyOccMaps :: IfM lcl (MaybeErr IfaceMessage KnownKeyNameMaps) loadKnownKeyOccMaps = do { eps <- getEps ; case eps_known_keys eps of { - Just (kk_maps, _) -> return kk_maps ; + Just (kk_maps, _) -> return (Succeeded kk_maps) ; Nothing -> -- We don't have a KnownKeyOccMap yet, so create it -- from the interface file for KnownKeyName do { hsc_env <- getTopEnv ; mb_res <- liftIO $ findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual - ; iface <- case mb_res of - Found _ mod -> loadInterfaceWithException doc mod ImportBySystem - fr -> do { hsc_env <- getTopEnv - ; pprPanic "loadKnownKeyOccMap" $ - missingInterfaceErrorDiagnostic defaultIfaceMessageOpts $ - cannotFindModule hsc_env eSSENTIALS_NAME fr } + ; case mb_res of + Found _ mod -> Succeeded <$> build_maps mod + fr -> return (Failed (CantFindEssentials + (cannotFindModule hsc_env eSSENTIALS_NAME fr) + UnknownLoadEssentialsReason)) + } } } + where + doc = text "Need interface for KnownKeyNames" + + build_maps :: Module -> IfM lcl KnownKeyNameMaps + build_maps mod + = do { iface <- loadInterfaceWithException doc mod ImportBySystem ; let kk_map :: UniqFM KnownKey Name -- Domain is just the KnownKeys in the knownKeyTable @@ -318,9 +332,7 @@ loadKnownKeyOccMaps (msg $$ text "Known-key occ-map" <+> ppr occ_map) Nothing -> return () #endif - ; return (kk_map, occ_map) } } } - where - doc = text "Need interface for KnonwKeyNames" + ; return (kk_map, occ_map) } lookupKnownKeysMap :: UniqFM KnownKey Name -> KnownKey -> MaybeErr IfaceMessage Name lookupKnownKeysMap kk_map key = case lookupUFM kk_map key of @@ -361,10 +373,13 @@ lookupKnownKeysModule hsc_env dflags = do found_essentials <- findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual let rebindable_kn = gopt Opt_RebindableKnownNames dflags let essentials_uid - | rebindable_kn = Nothing - | Found _ mod <- found_essentials = Just mod - | otherwise = Nothing - return essentials_uid + | rebindable_kn = return Nothing + | Found _ mod <- found_essentials = return (Just mod) + | fr <- found_essentials = do + throwOneError (initSourceErrorContext dflags) $ + mkPlainErrorMsgEnvelope noSrcSpan $ GhcDriverMessage $ DriverInterfaceError $ + CantFindEssentials (cannotFindModule hsc_env eSSENTIALS_NAME fr) LookingForEssentialsModule + essentials_uid {- ********************************************************************* * * ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -59,7 +59,7 @@ import GHC.Prelude import GHC.Iface.Load import GHC.Iface.Env -import GHC.Iface.Errors.Types( IfaceMessage(..) ) +import GHC.Iface.Errors.Types( IfaceMessage(..), LoadEssentialsReason (..) ) import GHC.Hs import GHC.Types.Name.Reader @@ -1044,10 +1044,15 @@ lookup_known_occ :: HasDebugCallStack => KnownEntitySource -> KnownOcc -> RnM (MaybeErr IfaceMessage Name) lookup_known_occ KES_FromModule occ - = do { (_, occ_map) <- initIfaceTcRn loadKnownKeyOccMaps - ; case lookupOccEnv occ_map occ of - Just name -> return (Succeeded name) - Nothing -> return (Failed (MissingKnownKey3 occ)) } + = do { mb_maps <- initIfaceTcRn loadKnownKeyOccMaps + ; return $ case mb_maps of + Failed (CantFindEssentials err UnknownLoadEssentialsReason) -- augment error + -> Failed (CantFindEssentials err (LookingForKnownOcc occ)) + Failed err -> Failed err + Succeeded (_, occ_map) -> + case lookupOccEnv occ_map occ of + Just name -> Succeeded name + Nothing -> Failed (MissingKnownKey3 occ) } lookup_known_occ (KES_InScope { ke_rdr_env = rdr_env }) occ = case lookupKnownGRE rdr_env occ of ===================================== compiler/GHC/Tc/Solver/Default.hs ===================================== @@ -1006,7 +1006,7 @@ applyDefaultingRules :: WantedConstraints -> TcS Bool -- See Note [How type-class constraints are defaulted] applyDefaultingRules wanteds - | isEmptyWC wanteds + | isSolvedWC wanteds -- not isEmptyWC, see (SCS5) in Note [Shortcut solving] = return False | otherwise = do { (default_env, extended_rules) <- getDefaultInfo ===================================== compiler/GHC/Tc/Solver/Dict.hs ===================================== @@ -671,6 +671,10 @@ Some wrinkles: don't want to reject short-cut solving just because we have some leftover /solved/ implications. #26805 was a case in point. +(SCS5) Similarly to (SCS4), `applyDefaultingRules` should use `isSolvedWC` not + `isEmptyWC`. This avoids unnecessarily trying defaulting rules on solved + constraints. + Note [Shortcut solving: incoherence] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This optimization relies on coherence of dictionaries to be correct. When we ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -83,7 +83,6 @@ import GHC.Driver.DynFlags import GHC.Builtin( isUnboundName ) import GHC.Builtin.KnownKeys import GHC.Builtin.WiredIn.Types -import GHC.Builtin.Modules ( eSSENTIALS_NAME ) import GHC.Runtime.Context @@ -116,7 +115,6 @@ import GHC.Unit.Home import GHC.Unit.Home.Graph import GHC.Unit.Home.ModInfo import GHC.Unit.External -import GHC.Unit.Finder import GHC.Utils.Outputable import GHC.Utils.Panic @@ -139,7 +137,6 @@ import GHC.Types.Id import GHC.Types.Id.Info ( RecSelParent(..) ) import GHC.Types.Name.Reader import GHC.Types.TyThing -import GHC.Types.PkgQual import GHC.Types.Unique.Set ( nonDetEltsUniqSet ) import qualified GHC.LanguageExtensions as LangExt @@ -1119,9 +1116,7 @@ tcGetDefaultTys :: TcM (DefaultEnv, -- Default classes and types Bool) -- True <=> Use extended defaulting rules tcGetDefaultTys = do { dflags <- getDynFlags - ; hsc_env <- getTopEnv ; let ovl_strings = xopt LangExt.OverloadedStrings dflags - rebindable_kn = gopt Opt_RebindableKnownNames dflags extended_defaults = xopt LangExt.ExtendedDefaultRules dflags -- See also #1974 builtinDefaults cls tys = ClassDefaults{ cd_class = cls @@ -1133,17 +1128,11 @@ tcGetDefaultTys ; user_defaults <- getDeclaredDefaultTys -- User-supplied defaults ; this_module <- tcg_mod <$> getGblEnv ; let this_unit = moduleUnit this_module - ; found_essentials <- liftIO $ findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual - ; case (found_essentials, rebindable_kn) of - (NotFound{}, False) -> -- See Wrinkle (KN5) in Note [Overview of known entities] - -- If GHC.Essentials isn't available at all when -fno-rebindable-known-names - -- don't add the built-in defaulting, bc e.g. Num is a known-entity. - return (user_defaults, extended_defaults) - _ | this_unit == ghcInternalUnit -> - -- see Remark [No built-in defaults in ghc-internal] - -- in Note [Builtin class defaults] in GHC.Tc.Utils.Env - return (user_defaults, extended_defaults) - _ -> do + ; if this_unit == ghcInternalUnit -- if we wanted, this needn't be about ghc-internal + -- see Remark [No built-in defaults in ghc-internal] + -- in Note [Builtin class defaults] in GHC.Tc.Utils.Env + then return (user_defaults, extended_defaults) + else do -- Not one of the built-in units -- @default Num (Integer, Double)@, plus extensions { extDef <- if extended_defaults ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -893,6 +893,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "MissingKnownKey2" = 71344 GhcDiagnosticCode "MissingKnownKey3" = 71345 GhcDiagnosticCode "KnownKeyScopeError" = 99040 + GhcDiagnosticCode "CantFindEssentials" = 49917 -- Out of scope errors GhcDiagnosticCode "NotInScope" = 76037 ===================================== docs/users_guide/separate_compilation.rst ===================================== @@ -1665,11 +1665,15 @@ flags: :type: dynamic :category: - This flag is off by default. It is typically set when compiling modules - in ``ghc-internal`` or ``base``, and tells GHC to look for a known - entity in the current top-level scope. When the flag is un-set, GHC looks - for the module ``base:GHC.KnownKeyNames``, but this module does not exist - when compiling ``ghc-internal`` or ``base``, which is why the flag is needed. + This flag is off by default. It tells GHC to look for a known entity in + the current top-level scope. When the flag is off, GHC looks for known + entities in the exports of module ``GHC.Essentials``. + + It is typically set when compiling modules in ``ghc-internal`` or ``base``, + since ``GHC.Essentials`` does not yet exist when compiling those packages. + + GHC must assume ``GHC.Essentials`` is an implicit module dependency when + and only when ``-fno-rebindable-known-names``. .. ghc-flag:: -fdefines-known-key-names :shortdesc: This module defines a known name ===================================== testsuite/tests/cabal/T27013a/Makefile ===================================== @@ -6,16 +6,16 @@ SETUP=./Setup -v0 # Reproducer for #27013 (!15899#note_676801). # -# The `composition` package depends on neither `base` nor `ghc-internal` -# (see composition.cabal: no build-depends). It uses NoImplicitPrelude -# and defines its own `(.)`. Building it should not require GHC to load -# known-key modules from `base` such as `GHC.Essentials`. +# `composition` depends on neither base nor ghc-internal and uses no known-key +# names AT ALL. We pass -frebindable-known-names just so GHC doesn't force an +# implicit GHC.Essentials dependency (which couldn't be solved because of +# -hide-all-packages). See T27013f for the failure when the flag is omitted. T27013a: clean '$(GHC_PKG)' init tmp.d '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup $(SETUP) clean - $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS)' --package-db=tmp.d + $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --with-hc-pkg='$(GHC_PKG)' --ghc-options='$(TEST_HC_OPTS) -frebindable-known-names' --package-db=tmp.d $(SETUP) build clean : ===================================== testsuite/tests/cabal/T27013d/Makefile ===================================== @@ -2,15 +2,18 @@ TOP=../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk -# Test that compiling Data.Composition without implicit Prelude does not -# recompile the second or third time. The `composition` package's -# Data.Composition uses NoImplicitPrelude and depends on neither base nor -# ghc-internal. In !15899, it was recompiled because of an incorrect -# "GHC.Essentials package changed". +# Test that compiling Data.Composition with -hide-all-packages and +# -XNoImplicitPrelude does not recompile the second or third time. In !15899, +# it used to recompile because of an incorrect "GHC.Essentials package changed". +# +# We pass -frebindable-known-names so GHC doesn't force an implicit +# GHC.Essentials dependency: despite this module not using known-key names, +# -hide-all-packages means we can't find GHC.Essentials when it is added as an +# implicit dependency. clean: rm -f *.o *.hi T27013d: clean - '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages - '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages - '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages -frebindable-known-names + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages -frebindable-known-names + '$(TEST_HC)' $(TEST_HC_OPTS) Composition.hs -XNoImplicitPrelude -hide-all-packages -frebindable-known-names ===================================== testsuite/tests/driver/T27013e/T27013e.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +-- This module is compiled with -hide-all-packages (see all.T), so neither +-- base nor GHC.Essentials can be found. The numeric literal forces GHC to +-- look up the known-key 'fromInteger', which it tries to resolve via the +-- exports of GHC.Essentials. Since GHC.Essentials cannot be found and +-- -frebindable-known-names is not in effect, this fails. +-- +-- We want a structured, helpful error here rather than a panic; see +-- GHC.Iface.Load.loadKnownKeyOccMaps. +module T27013e where + +n = 0 ===================================== testsuite/tests/driver/T27013e/T27013e.stderr ===================================== @@ -0,0 +1,13 @@ +T27013e.hs:13:5: error: [GHC-49917] + Failed to load the known-names module ‘GHC.Essentials’ from the visible packages + while looking for known-occ name ‘fromInteger’ + Did you mean to use ‘-package base’? + + Could not load module ‘GHC.Essentials’. + It is a member of the hidden package ‘base-4.23.0.0’. + Use -v to see a list of the files searched for. + + To lookup known-names in scope rather than in GHC.Essentials, + use ‘-frebindable-known-names’, and import + the necessary known-names definitions from ‘ghc-internal’. + ===================================== testsuite/tests/driver/T27013e/all.T ===================================== @@ -0,0 +1 @@ +test('T27013e', normalise_version('base'), compile_fail, ['-hide-all-packages']) ===================================== testsuite/tests/driver/T27013f/T27013f.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +-- Counterpart to T27013a/T27013d (see #27013, !15899). +-- +-- Like the `composition` package, this module needs no known-key. +-- It is compiled with -hide-all-packages (see all.T) and WITHOUT +-- -frebindable-known-names (unlike T27013{a,d}). +-- +-- Under the default -fno-rebindable-known-names, GHC must assume +-- GHC.Essentials is an implicit dependency and tries to discover its +-- package, which fails because nothing provides it. We want a structured +-- error here (not a panic) that points at -frebindable-known-names as the +-- way to avoid forcing that dependency. See GHC.Iface.Load. +module T27013f where + +(.) :: (b -> c) -> (a -> b) -> a -> c +(f . g) x = f (g x) ===================================== testsuite/tests/driver/T27013f/T27013f.stderr ===================================== @@ -0,0 +1,13 @@ +<no location info>: error: [GHC-49917] + Failed to load the known-names module ‘GHC.Essentials’ from the visible packages + while trying to discover its package + Did you mean to use ‘-package base’? + + Could not load module ‘GHC.Essentials’. + It is a member of the hidden package ‘base-4.23.0.0’. + Use -v to see a list of the files searched for. + + This error was triggered while trying to discover the package of ‘GHC.Essentials’, + rather than when looking up any specific known-name. + If you want to enforce ‘GHC.Essentials’ is not added to the module graph implicitly, + you should use ‘-frebindable-known-names’ ===================================== testsuite/tests/driver/T27013f/all.T ===================================== @@ -0,0 +1 @@ +test('T27013f', normalise_version('base'), compile_fail, ['-hide-all-packages']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac878ff32e63933b1f4268c7005129e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac878ff32e63933b1f4268c7005129e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Rodrigo Mesquita (@alt-romes)