Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC Commits: ac878ff3 by Rodrigo Mesquita at 2026-06-11T17:16:09+01:00 Better specification for when to disable defaulting - - - - - 2 changed files: - compiler/GHC/Builtin.hs - compiler/GHC/Tc/Utils/Env.hs Changes: ===================================== compiler/GHC/Builtin.hs ===================================== @@ -372,6 +372,11 @@ 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/Tc/Utils/Env.hs ===================================== @@ -1121,6 +1121,7 @@ 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,9 +1134,9 @@ tcGetDefaultTys ; this_module <- tcg_mod <$> getGblEnv ; let this_unit = moduleUnit this_module ; found_essentials <- liftIO $ findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual - ; case found_essentials of - NotFound{} -> - -- If GHC.Essentials isn't available at all (e.g. -hide-all-packages), + ; 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 -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac878ff32e63933b1f4268c7005129eb... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac878ff32e63933b1f4268c7005129eb... You're receiving this email because of your account on gitlab.haskell.org.