[Git][ghc/ghc][wip/int-index/mod-export-tests] Tests for -Wduplicate-exports, -Wdodgy-exports
Vladislav Zavialov pushed to branch wip/int-index/mod-export-tests at Glasgow Haskell Compiler / GHC Commits: 169bcac8 by Vladislav Zavialov at 2025-10-28T17:39:45+03:00 Tests for -Wduplicate-exports, -Wdodgy-exports Add test cases for the previously untested diagnostics: [GHC-51876] TcRnDupeModuleExport [GHC-64649] TcRnNullExportedModule This also revealed a typo (incorrect capitalization of "module") in the warning text for TcRnDupeModuleExport, which is now fixed. - - - - - 8 changed files: - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - testsuite/tests/diagnostic-codes/codes.stdout - + testsuite/tests/warnings/should_compile/DuplicateModExport.hs - + testsuite/tests/warnings/should_compile/DuplicateModExport.stderr - + testsuite/tests/warnings/should_compile/EmptyModExport.hs - + testsuite/tests/warnings/should_compile/EmptyModExport.stderr - testsuite/tests/warnings/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -619,7 +619,7 @@ instance Diagnostic TcRnMessage where TcRnDupeModuleExport mod -> mkSimpleDecorated $ hsep [ text "Duplicate" - , quotes (text "Module" <+> ppr mod) + , quotes (text "module" <+> ppr mod) , text "in export list" ] TcRnExportedModNotImported mod -> mkSimpleDecorated ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -1567,10 +1567,11 @@ data TcRnMessage where occurs when a module appears more than once in an export list. Example(s): - module Foo (module Bar, module Bar) - import Bar + module Foo (module Bar, module Bar) where + import Bar - Text cases: None + Text cases: + DuplicateModExport -} TcRnDupeModuleExport :: ModuleName -> TcRnMessage @@ -1590,10 +1591,11 @@ data TcRnMessage where when an export list contains a module that has no exports. Example(s): - module Foo (module Bar) where - import Bar () + module Foo (module Bar) where + import Bar () - Test cases: None + Test cases: + EmptyModExport -} TcRnNullExportedModule :: ModuleName -> TcRnMessage ===================================== testsuite/tests/diagnostic-codes/codes.stdout ===================================== @@ -50,8 +50,6 @@ [GHC-17268] is untested (constructor = TcRnCharLiteralOutOfRange) [GHC-36495] is untested (constructor = TcRnTagToEnumMissingValArg) [GHC-55868] is untested (constructor = TcRnArrowIfThenElsePredDependsOnResultTy) -[GHC-51876] is untested (constructor = TcRnDupeModuleExport) -[GHC-64649] is untested (constructor = TcRnNullExportedModule) [GHC-94558] is untested (constructor = TcRnExportHiddenComponents) [GHC-63055] is untested (constructor = TcRnFieldUpdateInvalidType) [GHC-26133] is untested (constructor = TcRnForeignImportPrimSafeAnn) ===================================== testsuite/tests/warnings/should_compile/DuplicateModExport.hs ===================================== @@ -0,0 +1,3 @@ +module DuplicateModExport (module L, module L) where + +import Data.List as L ===================================== testsuite/tests/warnings/should_compile/DuplicateModExport.stderr ===================================== @@ -0,0 +1,3 @@ +DuplicateModExport.hs:1:38: warning: [GHC-51876] [-Wduplicate-exports (in -Wdefault)] + Duplicate ‘module L’ in export list + ===================================== testsuite/tests/warnings/should_compile/EmptyModExport.hs ===================================== @@ -0,0 +1,3 @@ +module EmptyModExport (module L) where + +import Data.List as L () ===================================== testsuite/tests/warnings/should_compile/EmptyModExport.stderr ===================================== @@ -0,0 +1,3 @@ +EmptyModExport.hs:1:24: warning: [GHC-64649] [-Wdodgy-exports (in -Wextra)] + The export item ‘module L’ exports nothing + ===================================== testsuite/tests/warnings/should_compile/all.T ===================================== @@ -72,3 +72,5 @@ test('T23465', normal, compile, ['-ddump-parsed']) test('WarnNoncanonical', normal, compile, ['']) test('T24396', [extra_files(["T24396a.hs", "T24396b.hs"])], multimod_compile, ['T24396b', '']) test('SpecMultipleTys', normal, compile, ['']) # compile_fail from GHC 9.18 +test('DuplicateModExport', normal, compile, ['-Wduplicate-exports']) +test('EmptyModExport', normal, compile, ['-Wdodgy-exports']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/169bcac846d77a698459717e227d2852... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/169bcac846d77a698459717e227d2852... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Vladislav Zavialov (@int-index)