[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Suppress desugaring warnings in the pattern match checker
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3a9fcb50 by Luite Stegeman at 2026-04-13T09:35:10-04:00 Suppress desugaring warnings in the pattern match checker Avoid duplicating warnings from the actual desugaring pass. fixes #25996 - - - - - 41db422e by Phil de Joux at 2026-04-13T09:35:20-04:00 Typo ~/ghc/arch-os-version/environments - - - - - 70a21718 by Luite Stegeman at 2026-04-13T09:35:24-04:00 add changelog entry for #26233 - - - - - 7 changed files: - + changelog.d/fix-duplicate-pmc-warnings - + changelog.d/fix-ghci-duplicate-warnings-26233 - compiler/GHC/HsToCore/Pmc/Desugar.hs - docs/users_guide/packages.rst - + testsuite/tests/deSugar/should_compile/T25996.hs - + testsuite/tests/deSugar/should_compile/T25996.stderr - testsuite/tests/deSugar/should_compile/all.T Changes: ===================================== changelog.d/fix-duplicate-pmc-warnings ===================================== @@ -0,0 +1,6 @@ +section: compiler +synopsis: Fix duplicate desugaring warnings emitted by the pattern match checker. + The pattern match checker now suppresses warnings that are already reported + by the main desugaring pass. +issues: #25996 +mrs: !15859 ===================================== changelog.d/fix-ghci-duplicate-warnings-26233 ===================================== @@ -0,0 +1,4 @@ +section: ghci +synopsis: Fix duplicate warnings in GHCi when typechecking statements. +issues: #26233 +mrs: !15860 ===================================== compiler/GHC/HsToCore/Pmc/Desugar.hs ===================================== @@ -375,16 +375,18 @@ desugarConPatOut x con univ_tys ex_tvs dicts = \case desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre) -- See 'GrdPatBind' for how this simply repurposes GrdGRHS. -desugarPatBind loc var pat = +-- See Note [Suppress warnings in PMC desugaring] +desugarPatBind loc var pat = discardWarningsDs $ PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarPat var pat desugarEmptyCase :: Id -> DsM PmEmptyCase desugarEmptyCase var = pure PmEmptyCase { pe_var = var } -- | Desugar the non-empty 'Match'es of a 'MatchGroup'. +-- See Note [Suppress warnings in PMC desugaring] desugarMatches :: [Id] -> NonEmpty (LMatch GhcTc (LHsExpr GhcTc)) -> DsM (PmMatchGroup Pre) -desugarMatches vars matches = +desugarMatches vars matches = discardWarningsDs $ PmMatchGroup <$> traverse (desugarMatch vars) matches -- Desugar a single match @@ -398,8 +400,9 @@ desugarMatch vars (L match_loc (Match { m_pats = L _ pats, m_grhss = grhss })) = -- tracePm "desugarMatch" (vcat [ppr pats, ppr pats', ppr grhss']) return PmMatch { pm_pats = pats', pm_grhss = grhss' } +-- See Note [Suppress warnings in PMC desugaring] desugarGRHSs :: SrcSpan -> SDoc -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (PmGRHSs Pre) -desugarGRHSs match_loc pp_pats grhss = do +desugarGRHSs match_loc pp_pats grhss = discardWarningsDs $ do lcls <- desugarLocalBinds (grhssLocalBinds grhss) grhss' <- traverse (desugarLGRHS match_loc pp_pats) (grhssGRHSs grhss) return PmGRHSs { pgs_lcls = lcls, pgs_grhss = grhss' } @@ -593,6 +596,17 @@ The place to store the 'PmLet' guards for @where@ clauses (which are per 'GRHSs') is as a field of 'PmGRHSs'. For plain @let@ guards as in the guards of @x@, we can simply add them to the 'pg_grds' field of 'PmGRHS'. +Note [Suppress warnings in PMC desugaring] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This module uses 'dsLExpr', 'dsExpr', and 'dsSyntaxExpr' to desugar +expressions into Core for pattern match checking. The main desugaring +pass in GHC.HsToCore processes these same expressions too, so without +suppression any warnings would be emitted twice (#25996). + +To avoid this, the exported functions ('desugarPatBind', 'desugarMatches', +'desugarGRHSs') are wrapped in 'discardWarningsDs', covering all internal +desugarer calls without having to wrap each one individually. + Note [Desugaring -XStrict matches in Pmc] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider (#21761) ===================================== docs/users_guide/packages.rst ===================================== @@ -600,7 +600,7 @@ must be relative to the location of the package environment file. :category: Use the package environment in ⟨file⟩, or in - ``$XDG_DATA_HOME/ghc/arch-os-version/environments/⟨name⟩`` + ``$XDG_DATA_HOME/.ghc/arch-os-version/environments/⟨name⟩`` If set to ``-`` no package environment is read. .. envvar:: GHC_ENVIRONMENT @@ -613,13 +613,13 @@ locations: - File ⟨file⟩ if you pass the option :ghc-flag:`-package-env ⟨file⟩|⟨name⟩`. -- File ``$XDG_DATA_HOME/ghc/arch-os-version/environments/name`` if you pass the +- File ``$XDG_DATA_HOME/.ghc/arch-os-version/environments/name`` if you pass the option ``-package-env ⟨name⟩``. - File ⟨file⟩ if the environment variable :envvar:`GHC_ENVIRONMENT` is set to ⟨file⟩. -- File ``$XDG_DATA_HOME/ghc/arch-os-version/environments/name`` if the +- File ``$XDG_DATA_HOME/.ghc/arch-os-version/environments/name`` if the environment variable :envvar:`GHC_ENVIRONMENT` is set to ⟨name⟩. Additionally, unless ``-hide-all-packages`` is specified ``ghc`` will also @@ -628,7 +628,7 @@ look for the package environment in the following locations: - File ``.ghc.environment.arch-os-version`` if it exists in the current directory or any parent directory (but not the user's home directory). -- File ``$XDG_DATA_HOME/ghc/arch-os-version/environments/default`` if it +- File ``$XDG_DATA_HOME/.ghc/arch-os-version/environments/default`` if it exists. Package environments can be modified by further command line arguments; ===================================== testsuite/tests/deSugar/should_compile/T25996.hs ===================================== @@ -0,0 +1,17 @@ +{-# OPTIONS_GHC -Wall #-} +{-# OPTIONS_GHC -Wno-unused-local-binds #-} +{-# OPTIONS_GHC -Wno-unused-top-binds #-} + +main :: IO () +main = do + pure () + where + biz :: IO () + biz = do + pure (10 :: Integer) + pure () + +biz' :: IO () +biz' = do + pure (10 :: Integer) + pure () ===================================== testsuite/tests/deSugar/should_compile/T25996.stderr ===================================== @@ -0,0 +1,10 @@ +T25996.hs:11:7: warning: [GHC-81995] [-Wunused-do-bind (in -Wall)] + A do-notation statement discarded a result of type ‘Integer’ + Suggested fix: + Suppress this warning by saying ‘_ <- pure (10 :: Integer)’ + +T25996.hs:16:3: warning: [GHC-81995] [-Wunused-do-bind (in -Wall)] + A do-notation statement discarded a result of type ‘Integer’ + Suggested fix: + Suppress this warning by saying ‘_ <- pure (10 :: Integer)’ + ===================================== testsuite/tests/deSugar/should_compile/all.T ===================================== @@ -115,3 +115,4 @@ test('T19883', normal, compile, ['']) test('T22719', normal, compile, ['-ddump-simpl -dsuppress-uniques -dno-typeable-binds']) test('T23550', normal, compile, ['']) test('T24489', normal, compile, ['-O']) +test('T25996', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d40fba22933fa188a271031a99b267a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d40fba22933fa188a271031a99b267a... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)