Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

8 changed files:

Changes:

  • changelog.d/27380
    1
    +section: compiler
    
    2
    +synopsis: Don't suggest enabling ``ImportQualifiedPost`` when it is already enabled.
    
    3
    +  The :ghc-flag:`-Wprepositive-qualified-module` warning no longer suggests
    
    4
    +  enabling the extension if it is already in effect (as it is by default
    
    5
    +  under GHC2021).
    
    6
    +issues: #27380
    
    7
    +mrs: !16376

  • compiler/GHC/Parser/Errors/Ppr.hs
    ... ... @@ -113,7 +113,7 @@ instance Diagnostic PsMessage where
    113 113
                               <> if null prag then empty else text ":" <+> text prag
    
    114 114
         PsWarnMisplacedPragma prag
    
    115 115
           -> mkSimpleDecorated $ text "Misplaced" <+> pprFileHeaderPragmaType prag <+> text "pragma"
    
    116
    -    PsWarnImportPreQualified
    
    116
    +    PsWarnImportPreQualified _iqp_on
    
    117 117
           -> mkSimpleDecorated $
    
    118 118
                 text "Found" <+> quotes (text "qualified")
    
    119 119
                  <+> text "in prepositive position"
    
    ... ... @@ -603,7 +603,7 @@ instance Diagnostic PsMessage where
    603 603
         PsWarnStarIsType                              -> WarningWithFlag Opt_WarnStarIsType
    
    604 604
         PsWarnUnrecognisedPragma{}                    -> WarningWithFlag Opt_WarnUnrecognisedPragmas
    
    605 605
         PsWarnMisplacedPragma{}                       -> WarningWithFlag Opt_WarnMisplacedPragmas
    
    606
    -    PsWarnImportPreQualified                      -> WarningWithFlag Opt_WarnPrepositiveQualifiedModule
    
    606
    +    PsWarnImportPreQualified{}                    -> WarningWithFlag Opt_WarnPrepositiveQualifiedModule
    
    607 607
         PsWarnViewPatternSignatures{}                 -> WarningWithFlag Opt_WarnViewPatternSignatures
    
    608 608
         PsErrLexer{}                                  -> ErrorWithoutFlag
    
    609 609
         PsErrCmmLexer                                 -> ErrorWithoutFlag
    
    ... ... @@ -735,8 +735,10 @@ instance Diagnostic PsMessage where
    735 735
               then noHints
    
    736 736
               else [SuggestCorrectPragmaName suggestions]
    
    737 737
         PsWarnMisplacedPragma{}                       -> [SuggestPlacePragmaInHeader]
    
    738
    -    PsWarnImportPreQualified                      -> [ SuggestQualifiedAfterModuleName
    
    739
    -                                                     , suggestExtension LangExt.ImportQualifiedPost]
    
    738
    +    PsWarnImportPreQualified iqp_on | iqp_on     -> [ SuggestQualifiedAfterModuleName ]
    
    739
    +                                    | otherwise  -> [ SuggestQualifiedAfterModuleName
    
    740
    +                                                    , suggestExtension LangExt.ImportQualifiedPost
    
    741
    +                                                    ]
    
    740 742
         PsWarnViewPatternSignatures{}                 -> [SuggestParenthesizePatternRHS]
    
    741 743
         PsErrLexer{}                                  -> noHints
    
    742 744
         PsErrCmmLexer                                 -> noHints
    

  • compiler/GHC/Parser/Errors/Types.hs
    ... ... @@ -133,7 +133,7 @@ data PsMessage
    133 133
        | PsWarnStarIsType
    
    134 134
     
    
    135 135
        -- | Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled
    
    136
    -   | PsWarnImportPreQualified
    
    136
    +   | PsWarnImportPreQualified !Bool -- is 'ImportQualifiedPost' enabled?
    
    137 137
     
    
    138 138
        | PsWarnOperatorWhitespaceExtConflict !OperatorWhitespaceSymbol
    
    139 139
     
    

  • compiler/GHC/Parser/PostProcess.hs
    ... ... @@ -1326,7 +1326,7 @@ checkImportDecl mPre mPost preLevel postLevel = do
    1326 1326
       -- Warn if 'qualified' found in prepositive position and
    
    1327 1327
       -- 'Opt_WarnPrepositiveQualifiedModule' is enabled.
    
    1328 1328
       whenJust mPre $ \pre ->
    
    1329
    -    warnPrepositiveQualifiedModule (tokenSpan pre)
    
    1329
    +    warnPrepositiveQualifiedModule (tokenSpan pre) importQualifiedPostEnabled
    
    1330 1330
     
    
    1331 1331
       return (qualSpec, levelSpec)
    
    1332 1332
     
    
    ... ... @@ -3498,9 +3498,9 @@ isImpExpQcWildcard _ = False
    3498 3498
     -----------------------------------------------------------------------------
    
    3499 3499
     -- Warnings and failures
    
    3500 3500
     
    
    3501
    -warnPrepositiveQualifiedModule :: SrcSpan -> P ()
    
    3502
    -warnPrepositiveQualifiedModule span =
    
    3503
    -  addPsMessage span PsWarnImportPreQualified
    
    3501
    +warnPrepositiveQualifiedModule :: SrcSpan -> Bool -> P ()
    
    3502
    +warnPrepositiveQualifiedModule span qualifiedPostEnabled =
    
    3503
    +  addPsMessage span $ PsWarnImportPreQualified qualifiedPostEnabled
    
    3504 3504
     
    
    3505 3505
     failNotEnabledImportQualifiedPost :: SrcSpan -> P ()
    
    3506 3506
     failNotEnabledImportQualifiedPost loc =
    

  • testsuite/tests/module/T27380.hs
    1
    +{-# LANGUAGE NoImportQualifiedPost #-}
    
    2
    +{-# OPTIONS_GHC -Wprepositive-qualified-module #-}
    
    3
    +-- Negative control for #27380: with the extension explicitly disabled,
    
    4
    +-- the ImportQualifiedPost suggestion must still appear.
    
    5
    +import qualified System.IO
    
    6
    +main :: IO ()
    
    7
    +main = System.IO.print "hi"

  • testsuite/tests/module/T27380.stderr
    1
    +T27380.hs:5:8: warning: [GHC-07924] [-Wprepositive-qualified-module]
    
    2
    +    Found ‘qualified’ in prepositive position
    
    3
    +    Suggested fixes:
    
    4
    +      • Place ‘qualified’ after the module name.
    
    5
    +      • Perhaps you intended to use the ‘ImportQualifiedPost’ extension
    
    6
    +

  • testsuite/tests/module/all.T
    ... ... @@ -295,3 +295,4 @@ test('T21826', normal, compile_fail, [''])
    295 295
     test('T20007', normal, compile_fail, [''])
    
    296 296
     test('T25901_imp_plain_wc', normal, compile_fail, [''])
    
    297 297
     test('T25901_exp_plain_wc', normal, compile_fail, [''])
    
    298
    +test('T27380', normal, compile, [''])

  • testsuite/tests/module/mod184.stderr
    1
    -
    
    2 1
     mod184.hs:6:8: warning: [GHC-07924] [-Wprepositive-qualified-module]
    
    3 2
         Found ‘qualified’ in prepositive position
    
    4
    -    Suggested fixes:
    
    5
    -      • Place ‘qualified’ after the module name.
    
    6
    -      • Perhaps you intended to use the ‘ImportQualifiedPost’ extension
    3
    +    Suggested fix: Place ‘qualified’ after the module name.
    
    4
    +