Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 86c82745 by Vladislav Zavialov at 2025-11-01T07:24:29-04:00 Supplant TcRnExportHiddenComponents with TcRnDodgyExports (#26534) Remove a bogus special case in lookup_ie_kids_all, making TcRnExportHiddenComponents obsolete. - - - - - 10 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Types/Error/Codes.hs - testsuite/tests/diagnostic-codes/codes.stdout - + testsuite/tests/warnings/should_compile/DodgyExports02.hs - + testsuite/tests/warnings/should_compile/DodgyExports02.stderr - + testsuite/tests/warnings/should_compile/DodgyExports03.hs - + testsuite/tests/warnings/should_compile/DodgyExports03.stderr - testsuite/tests/warnings/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -636,11 +636,6 @@ instance Diagnostic TcRnMessage where $ formatExportItemError (text "module" <+> ppr mod) "is missing an export list" - TcRnExportHiddenComponents export_item - -> mkSimpleDecorated - $ formatExportItemError - (ppr export_item) - "attempts to export constructors or class methods that are not visible here" TcRnExportHiddenDefault export_item -> mkSimpleDecorated $ formatExportItemError @@ -2231,8 +2226,6 @@ instance Diagnostic TcRnMessage where -> WarningWithFlag Opt_WarnDodgyExports TcRnMissingExportList{} -> WarningWithFlag Opt_WarnMissingExportList - TcRnExportHiddenComponents{} - -> ErrorWithoutFlag TcRnExportHiddenDefault{} -> ErrorWithoutFlag TcRnDuplicateExport{} @@ -2904,8 +2897,6 @@ instance Diagnostic TcRnMessage where -> noHints TcRnMissingExportList{} -> noHints - TcRnExportHiddenComponents{} - -> noHints TcRnExportHiddenDefault{} -> noHints TcRnDuplicateExport{} ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -1608,15 +1608,6 @@ data TcRnMessage where -} TcRnMissingExportList :: ModuleName -> TcRnMessage - {-| TcRnExportHiddenComponents is an error that occurs when an export contains - constructor or class methods that are not visible. - - Example(s): None - - Test cases: None - -} - TcRnExportHiddenComponents :: IE GhcPs -> TcRnMessage - {-| TcRnExportHiddenDefault is an error that occurs when an export contains a class default (with language extension NamedDefaults) that is not visible. ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -526,7 +526,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod } (L loc ie@(IEThingAll (warn_txt_ps, ann) l doc)) = do mb_gre <- lookupGreAvailRn (ieLWrappedNameWhatLooking l) $ lieWrappedName l for mb_gre $ \ par -> do - all_kids <- lookup_ie_kids_all ie l par + all_kids <- lookup_ie_kids_all l par let name = greName par all_gres = par : all_kids all_names = map greName all_gres @@ -562,7 +562,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod wc_kids <- case wc of NoIEWildcard -> return [] - IEWildcard _ -> lookup_ie_kids_all ie l par + IEWildcard _ -> lookup_ie_kids_all l par let name = greName par all_kids = with_kids ++ wc_kids @@ -595,20 +595,15 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod ; kids <- lookupChildrenExport gre child_gres sub_rdrs ; return (unzip kids) } - lookup_ie_kids_all :: IE GhcPs -> LIEWrappedName GhcPs -> GlobalRdrElt + lookup_ie_kids_all :: LIEWrappedName GhcPs -> GlobalRdrElt -> RnM [GlobalRdrElt] - lookup_ie_kids_all ie (L _loc rdr) gre = + lookup_ie_kids_all (L _loc rdr) gre = do { let name = greName gre gres = findChildren kids_env name -- We only choose level 0 exports when filling in part of an export list implicitly. ; let kids_0 = mapMaybe pickLevelZeroGRE gres ; addUsedKids (ieWrappedName rdr) kids_0 - ; when (null kids_0) $ - if isTyConName name - then addTcRnDiagnostic (TcRnDodgyExports gre) - else -- This occurs when you export T(..), but - -- only import T abstractly, or T is a synonym. - addErr (TcRnExportHiddenComponents ie) + ; when (null kids_0) $ addTcRnDiagnostic (TcRnDodgyExports gre) ; return kids_0 } ------------- ===================================== compiler/GHC/Types/Error/Codes.hs ===================================== @@ -505,7 +505,7 @@ type family GhcDiagnosticCode c = n | n -> c where GhcDiagnosticCode "TcRnExportedModNotImported" = 90973 GhcDiagnosticCode "TcRnNullExportedModule" = 64649 GhcDiagnosticCode "TcRnMissingExportList" = 85401 - GhcDiagnosticCode "TcRnExportHiddenComponents" = 94558 + GhcDiagnosticCode "TcRnExportHiddenComponents" = Outdated 94558 GhcDiagnosticCode "TcRnExportHiddenDefault" = 74775 GhcDiagnosticCode "TcRnDuplicateExport" = 47854 GhcDiagnosticCode "TcRnDuplicateNamedDefaultExport" = 31584 ===================================== testsuite/tests/diagnostic-codes/codes.stdout ===================================== @@ -50,7 +50,6 @@ [GHC-17268] is untested (constructor = TcRnCharLiteralOutOfRange) [GHC-36495] is untested (constructor = TcRnTagToEnumMissingValArg) [GHC-55868] is untested (constructor = TcRnArrowIfThenElsePredDependsOnResultTy) -[GHC-94558] is untested (constructor = TcRnExportHiddenComponents) [GHC-63055] is untested (constructor = TcRnFieldUpdateInvalidType) [GHC-26133] is untested (constructor = TcRnForeignImportPrimSafeAnn) [GHC-03355] is untested (constructor = TcRnIllegalForeignDeclBackend) ===================================== testsuite/tests/warnings/should_compile/DodgyExports02.hs ===================================== @@ -0,0 +1,7 @@ +module DodgyExports02 + ( Identity(..) -- type constructor has out-of-scope children + , Void(..) -- type constructor has no children + ) where + +import Data.Void (Void) +import Data.Functor.Identity (Identity) ===================================== testsuite/tests/warnings/should_compile/DodgyExports02.stderr ===================================== @@ -0,0 +1,10 @@ +DodgyExports02.hs:2:5: warning: [GHC-75356] [-Wdodgy-exports (in -Wextra)] + The export item ‘Identity(..)’ suggests that + ‘Identity’ has (in-scope) constructors or record fields, + but it has none + +DodgyExports02.hs:3:5: warning: [GHC-75356] [-Wdodgy-exports (in -Wextra)] + The export item ‘Void(..)’ suggests that + ‘Void’ has (in-scope) constructors or record fields, + but it has none + ===================================== testsuite/tests/warnings/should_compile/DodgyExports03.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE ExplicitNamespaces #-} + +module DodgyExports03 + ( data MkR(..) -- data constructors never have children ('fld' belongs to 'R') + ) where + +data R = MkR { fld :: Int } ===================================== testsuite/tests/warnings/should_compile/DodgyExports03.stderr ===================================== @@ -0,0 +1,4 @@ +DodgyExports03.hs:4:5: warning: [GHC-75356] [-Wdodgy-exports (in -Wextra)] + The export item ‘MkR(..)’ suggests that + ‘MkR’ has children, but it is not a type constructor or a class + ===================================== testsuite/tests/warnings/should_compile/all.T ===================================== @@ -54,6 +54,8 @@ test('T19564d', normal, compile, ['']) # Also, suppress uniques as one of the warnings is unstable in CI, otherwise. test('T19296', normal, compile, ['-fdiagnostics-show-caret -Wredundant-constraints -dsuppress-uniques']) test('DodgyExports01', normal, compile, ['-Wdodgy-exports']) +test('DodgyExports02', normal, compile, ['-Wdodgy-exports']) +test('DodgyExports03', normal, compile, ['-Wdodgy-exports']) test('DerivingTypeable', normal, compile, ['-Wderiving-typeable']) test('T18862a', normal, compile, ['']) test('T18862b', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86c8274513318478b77d4286c2783acb... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86c8274513318478b77d4286c2783acb... You're receiving this email because of your account on gitlab.haskell.org.