| ... |
... |
@@ -375,16 +375,18 @@ desugarConPatOut x con univ_tys ex_tvs dicts = \case |
|
375
|
375
|
|
|
376
|
376
|
desugarPatBind :: SrcSpan -> Id -> Pat GhcTc -> DsM (PmPatBind Pre)
|
|
377
|
377
|
-- See 'GrdPatBind' for how this simply repurposes GrdGRHS.
|
|
378
|
|
-desugarPatBind loc var pat =
|
|
|
378
|
+-- See Note [Suppress warnings in PMC desugaring]
|
|
|
379
|
+desugarPatBind loc var pat = discardWarningsDs $
|
|
379
|
380
|
PmPatBind . flip PmGRHS (SrcInfo (L loc (ppr pat))) <$> desugarPat var pat
|
|
380
|
381
|
|
|
381
|
382
|
desugarEmptyCase :: Id -> DsM PmEmptyCase
|
|
382
|
383
|
desugarEmptyCase var = pure PmEmptyCase { pe_var = var }
|
|
383
|
384
|
|
|
384
|
385
|
-- | Desugar the non-empty 'Match'es of a 'MatchGroup'.
|
|
|
386
|
+-- See Note [Suppress warnings in PMC desugaring]
|
|
385
|
387
|
desugarMatches :: [Id] -> NonEmpty (LMatch GhcTc (LHsExpr GhcTc))
|
|
386
|
388
|
-> DsM (PmMatchGroup Pre)
|
|
387
|
|
-desugarMatches vars matches =
|
|
|
389
|
+desugarMatches vars matches = discardWarningsDs $
|
|
388
|
390
|
PmMatchGroup <$> traverse (desugarMatch vars) matches
|
|
389
|
391
|
|
|
390
|
392
|
-- Desugar a single match
|
| ... |
... |
@@ -398,8 +400,9 @@ desugarMatch vars (L match_loc (Match { m_pats = L _ pats, m_grhss = grhss })) = |
|
398
|
400
|
-- tracePm "desugarMatch" (vcat [ppr pats, ppr pats', ppr grhss'])
|
|
399
|
401
|
return PmMatch { pm_pats = pats', pm_grhss = grhss' }
|
|
400
|
402
|
|
|
|
403
|
+-- See Note [Suppress warnings in PMC desugaring]
|
|
401
|
404
|
desugarGRHSs :: SrcSpan -> SDoc -> GRHSs GhcTc (LHsExpr GhcTc) -> DsM (PmGRHSs Pre)
|
|
402
|
|
-desugarGRHSs match_loc pp_pats grhss = do
|
|
|
405
|
+desugarGRHSs match_loc pp_pats grhss = discardWarningsDs $ do
|
|
403
|
406
|
lcls <- desugarLocalBinds (grhssLocalBinds grhss)
|
|
404
|
407
|
grhss' <- traverse (desugarLGRHS match_loc pp_pats) (grhssGRHSs grhss)
|
|
405
|
408
|
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 |
|
593
|
596
|
'GRHSs') is as a field of 'PmGRHSs'. For plain @let@ guards as in the guards of
|
|
594
|
597
|
@x@, we can simply add them to the 'pg_grds' field of 'PmGRHS'.
|
|
595
|
598
|
|
|
|
599
|
+Note [Suppress warnings in PMC desugaring]
|
|
|
600
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
601
|
+This module uses 'dsLExpr', 'dsExpr', and 'dsSyntaxExpr' to desugar
|
|
|
602
|
+expressions into Core for pattern match checking. The main desugaring
|
|
|
603
|
+pass in GHC.HsToCore processes these same expressions too, so without
|
|
|
604
|
+suppression any warnings would be emitted twice (#25996).
|
|
|
605
|
+
|
|
|
606
|
+To avoid this, the exported functions ('desugarPatBind', 'desugarMatches',
|
|
|
607
|
+'desugarGRHSs') are wrapped in 'discardWarningsDs', covering all internal
|
|
|
608
|
+desugarer calls without having to wrap each one individually.
|
|
|
609
|
+
|
|
596
|
610
|
Note [Desugaring -XStrict matches in Pmc]
|
|
597
|
611
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
598
|
612
|
Consider (#21761)
|