Simon Peyton Jones pushed to branch wip/T27731 at Glasgow Haskell Compiler / GHC

Commits:

8 changed files:

Changes:

  • compiler/GHC/Rename/Module.hs
    ... ... @@ -2517,8 +2517,8 @@ rnInjectivityAnn :: LHsQTyVars GhcRn -- ^ Type variables declared in
    2517 2517
     rnInjectivityAnn tvBndrs (L _ (TyVarSig _ resTv))
    
    2518 2518
                      (L srcSpan (InjectivityAnn x injFrom injTo))
    
    2519 2519
      = do
    
    2520
    -   { (injDecl'@(L _ (InjectivityAnn _ injFrom' injTo')), noRnErrors)
    
    2521
    -          <- askNoErrs $
    
    2520
    +   { (injDecl'@(L _ (InjectivityAnn _ injFrom' injTo')), rn_errors)
    
    2521
    +          <- askErrsFound $
    
    2522 2522
                  bindLocalNames (maybeToList (hsLTyVarName resTv)) $
    
    2523 2523
                  -- The return type variable scopes over the injectivity annotation
    
    2524 2524
                  -- e.g.   type family F a = (r::*) | r -> a
    
    ... ... @@ -2540,11 +2540,11 @@ rnInjectivityAnn tvBndrs (L _ (TyVarSig _ resTv))
    2540 2540
        -- if renaming of type variables ended with errors (eg. there were
    
    2541 2541
        -- not-in-scope variables) don't check the validity of injectivity
    
    2542 2542
        -- annotation. This gives better error messages.
    
    2543
    -   ; when (noRnErrors && not lhsValid) $
    
    2543
    +   ; unless (rn_errors || lhsValid) $
    
    2544 2544
             addErrAt (getLocA injFrom) $
    
    2545 2545
               TcRnIncorrectTyVarOnLhsOfInjCond resName injFrom
    
    2546 2546
     
    
    2547
    -   ; when (noRnErrors && not (Set.null rhsValid)) $
    
    2547
    +   ; unless (rn_errors || Set.null rhsValid) $
    
    2548 2548
           do { let errorVars = Set.toList rhsValid
    
    2549 2549
              ; addErrAt (locA srcSpan) $
    
    2550 2550
                   TcRnUnknownTyVarsOnRhsOfInjCond errorVars } } }
    
    ... ... @@ -2561,7 +2561,7 @@ rnInjectivityAnn tvBndrs (L _ (TyVarSig _ resTv))
    2561 2561
     -- this time we expect "result" to be reported not in scope by rnLTyVar.
    
    2562 2562
     rnInjectivityAnn _ _ (L srcSpan (InjectivityAnn x injFrom injTo)) =
    
    2563 2563
        setSrcSpanA srcSpan $ do
    
    2564
    -   (injDecl', _) <- askNoErrs $ do
    
    2564
    +   (injDecl', _) <- askErrsFound $ do
    
    2565 2565
          injFrom' <- rnLTyVar injFrom
    
    2566 2566
          injTo'   <- mapM rnLTyVar injTo
    
    2567 2567
          return $ L srcSpan (InjectivityAnn x (fmap greName injFrom') (fmap (fmap greName) injTo'))
    

  • compiler/GHC/Tc/Errors.hs
    ... ... @@ -262,7 +262,7 @@ report_unsolved type_errors expr_holes
    262 262
                                 , cec_expr_holes         = expr_holes
    
    263 263
                                 , cec_type_holes         = type_holes
    
    264 264
                                 , cec_out_of_scope_holes = out_of_scope_holes
    
    265
    -                            , cec_suppress           = False
    
    265
    +                            , cec_outer_err          = False
    
    266 266
                                 , cec_warn_redundant     = warn_redundant
    
    267 267
                                 , cec_expand_syns        = exp_syns
    
    268 268
                                 , cec_binds              = binds_var }
    
    ... ... @@ -317,26 +317,26 @@ we just switch off deferred type errors altogether. See #14605.
    317 317
     This is done by maybeSwitchOffDefer.  It's also useful in one other
    
    318 318
     place: see Note [Wrapping failing kind equalities] in GHC.Tc.Solver.
    
    319 319
     
    
    320
    -Note [cec_suppress: suppressing less-important error messages]
    
    320
    +Note [cec_outer_err: suppressing less-important error messages]
    
    321 321
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    322
    -The cec_suppress flag says "don't report any less-important errors".  Instead, just create
    
    322
    +The cec_outer_err flag says "don't report any less-important errors".  Instead, just create
    
    323 323
     evidence bindings (as usual).  It's used when more important errors have occurred
    
    324
    -(or will occur) eleswhere.
    
    324
    +(or will occur) elsewhere.
    
    325 325
     
    
    326 326
     (SLIE0)
    
    327
    -  * Note that `cec_suppress` does not affect more-important errors, namely the `report1`
    
    327
    +  * Note that `cec_outer_err` does not affect more-important errors, namely the `report1`
    
    328 328
         group in `reportWanteds`
    
    329
    -  * But `cec_suppress` /does/ affect the less-important errors, namely the `report2` group.
    
    329
    +  * But `cec_outer_err` /does/ affect the less-important errors, namely the `report2` group.
    
    330 330
       To see this, look at the plumbing of cec suppress in `reportWanteds`
    
    331 331
     
    
    332
    -(SLIE1) When we begin `reportAllUnsolved` we set `cec_suppress` if there are insoluble
    
    332
    +(SLIE1) When we begin `reportAllUnsolved` we set `cec_outer_err` if there are insoluble
    
    333 333
       wanteds /anywhere/ in the tree, via `insolubleWC`.  That means we'll suppress all
    
    334 334
       less-important errors in favour of the more important (insolbule) ones
    
    335 335
     
    
    336 336
     (SLIE2) But we need to take care: flags can turn errors into warnings, and we
    
    337 337
       don't want those warnings to suppress subsequent errors (including
    
    338 338
       suppressing the essential addTcEvBind for them: #15152). So in
    
    339
    -  tryReporter we use askNoErrs to see if any error messages were
    
    339
    +  tryReporter we use askErrsFound to see if any error messages were
    
    340 340
       /actually/ produced; if not, we don't switch on suppression.
    
    341 341
     
    
    342 342
       A consequence is that warnings never suppress warnings, so turning an
    
    ... ... @@ -344,11 +344,11 @@ evidence bindings (as usual). It's used when more important errors have occurre
    344 344
       previously suppressed.   (e.g. partial-sigs/should_fail/T14584)
    
    345 345
     
    
    346 346
     (SLIE3) There is a tricky interaction between
    
    347
    -   * `cec_suppress` (a global flag) and
    
    347
    +   * `cec_outer_err` (a global flag) and
    
    348 348
        * `ei_suppress` (a local, per-error-item flag),
    
    349 349
          see Note [ei_suppress: suppressing confusing errors]
    
    350 350
     
    
    351
    -   Suppose the global `cec_suppress` is True because of an insoluble constraint
    
    351
    +   Suppose the global `cec_outer_err` is True because of an insoluble constraint
    
    352 352
        arising from a superclass constraint of an unsolved dictionary `[W] d::C a`.
    
    353 353
        This constraint will have ei_suppress=True. We must not suppress that less-insoluble
    
    354 354
        constraint `[W] d::C a`, lest we get no error at all (#18851).
    
    ... ... @@ -379,23 +379,27 @@ Which errors should be suppressed?
    379 379
     
    
    380 380
     There are wrinkles
    
    381 381
     
    
    382
    -(SCE3) In rare cases we may suppress /all/ errors. That is catastrophic: GHC proceeds
    
    383
    -  to desugar and optimise the program, even though it is full of type errors (#22702,
    
    384
    -  #22793), and/or we fail to bind evidence (#27731).
    
    382
    +(SCE3) In rare cases, `ei_suppress` may be True for /all/ errors in the Wanteds
    
    383
    +   of an implication.  Then we may report no error at all.  And if the entire
    
    384
    +   tree has this property (e.g. there is only one implication) we get
    
    385
    +   catastrophe: GHC proceeds to desugar and optimise the program, even though it
    
    386
    +   is full of type errors (#22702, #22793), and/or we fail to bind evidence
    
    387
    +   (#27731).
    
    385 388
     
    
    386
    -  If this happens, unless we are sure that an error will be reported some other way
    
    387
    -  (details in the defn of `tidy_items` in `reportWanteds), we just un-suppress the lot,
    
    388
    -  which is brutal but safe.  It's a rare case.
    
    389
    +   Solution: if all the Wanted constraints of an implication have `ei_suppress` set,
    
    390
    +   just un-suppress all of them. Brutal but safe.  It's a rare case.
    
    389 391
     
    
    390 392
        How can it happen that there are /all/ errors are suppressed?
    
    391 393
        * See test T18851 for an example of how it is (just, barely) possible for the
    
    392 394
          /only/ errors to be superclass-of-Wanted constraints.
    
    395
    +
    
    393 396
        * Similarly #27731, which also involves a superclass-of-Wanted:
    
    394 397
               class (a ~ F b) => Ren a b
    
    395 398
          If we have a [W] Ren a b, we'll emit the superclass [W] a ~ F b, which will
    
    396 399
          rewrite the original class constraint to [W] Ren (F b) b.  Now we have two
    
    397 400
          constraints: one has a non-empty rewriter set (SEC1) and one is a superclass of
    
    398 401
          a Wanted (SEC2).
    
    402
    +
    
    399 403
        * Also see Wrinkle (PER2) in Note [Prioritise Wanteds with empty
    
    400 404
          CoHoleSet] in GHC.Tc.Types.Constraint.
    
    401 405
     
    
    ... ... @@ -482,7 +486,7 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs
    482 486
                       , cec_encl     = implic' : cec_encl ctxt
    
    483 487
     
    
    484 488
     -- NO LONGER NEEDED
    
    485
    ---                   , cec_suppress =  cec_suppress ctxt
    
    489
    +--                   , cec_outer_err =  cec_outer_err ctxt
    
    486 490
                             -- Suppress inessential errors if there
    
    487 491
                             -- are insolubles anywhere in the
    
    488 492
                             -- tree rooted here, or we've come across
    
    ... ... @@ -542,6 +546,26 @@ reportBadTelescope ctxt env (ForAllSkol telescope) skols
    542 546
     reportBadTelescope _ _ skol_info skols
    
    543 547
       = pprPanic "reportBadTelescope" (ppr skol_info $$ ppr skols)
    
    544 548
     
    
    549
    +
    
    550
    +
    
    551
    +mkErrorItems :: SolverReportErrCtxt -> [Ct] -> TcM [ErrorItem]
    
    552
    +-- Turn each constraint into an ErrorItem
    
    553
    +-- Make sure that they aren't all suppressed via ei_suppress
    
    554
    +mkErrorItems ctxt cts
    
    555
    +  = do { items <- mapMaybeM mkErrorItem cts
    
    556
    +
    
    557
    +       -- Catch an awkward (and probably rare) case in which /all/ errors are
    
    558
    +       -- suppressed: see (SCE3) in Note [ei_suppress: suppressing confusing errors]
    
    559
    +       ; return (if need_to_unsuppress items
    
    560
    +                 then map unsuppressErrorItem items
    
    561
    +                 else items) }
    
    562
    +   where
    
    563
    +     need_to_unsuppress items
    
    564
    +       = not (cec_outer_err ctxt)          -- Have not already reported an error
    
    565
    +                                           -- in an outer implication); see #21405
    
    566
    +         && not (any ignoreConstraint cts) -- No error is ignorable (is reported elsewhere)
    
    567
    +         && all ei_suppress items          -- All errors are suppressed
    
    568
    +
    
    545 569
     -- | Makes an error item from a constraint, calculating whether or not the item
    
    546 570
     -- should be suppressed. See Note [Wanteds rewrite Wanteds: rewriter-sets]
    
    547 571
     -- in GHC.Tc.Types.Constraint. Returns Nothing if we should just ignore
    
    ... ... @@ -573,9 +597,8 @@ mkErrorItem ct
    573 597
                                 , ei_suppress  = suppressCtError ev }}
    
    574 598
     
    
    575 599
     -- | Actually report this 'ErrorItem'.
    
    576
    --- NOT NEEDED ANY MORE
    
    577
    ---unsuppressErrorItem :: ErrorItem -> ErrorItem
    
    578
    --- unsuppressErrorItem ei = ei { ei_suppress = False }
    
    600
    +unsuppressErrorItem :: ErrorItem -> ErrorItem
    
    601
    +unsuppressErrorItem ei = ei { ei_suppress = False }
    
    579 602
     
    
    580 603
     -- | Should we completely ignore this constraint in error reporting?
    
    581 604
     -- It *must* be the case that any constraint for which this returns True
    
    ... ... @@ -651,39 +674,20 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    651 674
       | otherwise
    
    652 675
       = do { let tidy_cts  = bagToList (mapBag (tidyCt env)           simples)
    
    653 676
                  tidy_errs = bagToList (mapBag (tidyDelayedError env) errs)
    
    677
    +       ; tidy_items <- mkErrorItems ctxt tidy_cts
    
    654 678
     
    
    655
    -       ; tidy_items1 <- mapMaybeM mkErrorItem tidy_cts
    
    656
    -
    
    657
    -         -- Catch an awkward (and probably rare) case in which /all/ errors are
    
    658
    -         -- suppressed: see (SCE3) in Note [ei_suppress: suppressing confusing errors]
    
    659
    ---       ; errs_already <- ifErrsM (return True) (return False)
    
    660
    -       ; let tidy_items
    
    661
    --- NO LONGER NEEDED
    
    662
    ---               | not errs_already                     -- Have not already reported an error (perhaps
    
    663
    ---                                                      --   from an outer implication); see #21405
    
    664
    ---               , not (any ignoreConstraint simples)   -- No error is ignorable (is reported elsewhere)
    
    665
    ---               , all ei_suppress tidy_items1          -- All errors are suppressed
    
    666
    ---               = map unsuppressErrorItem tidy_items1
    
    667
    ---
    
    668
    ---               | otherwise
    
    669
    -               = tidy_items1
    
    670
    -
    
    671
    -       ; traceTc "reportWanteds 1" (vcat [ text "Simples =" <+> ppr simples
    
    672
    -                                         , text "Suppress =" <+> ppr (cec_suppress ctxt)
    
    679
    +       ; traceTc "reportWanteds 1" (vcat [ text "Simples    =" <+> ppr simples
    
    680
    +                                         , text "Suppress   =" <+> ppr (cec_outer_err ctxt)
    
    673 681
                                              , text "tidy_cts   =" <+> ppr tidy_cts
    
    674
    -                                         , text "tidy_items1 =" <+> ppr tidy_items1
    
    675
    -                                         , text "tidy_errs =" <+> ppr tidy_errs ])
    
    682
    +                                         , text "tidy_items =" <+> ppr tidy_items
    
    683
    +                                         , text "tidy_errs  =" <+> ppr tidy_errs ])
    
    676 684
     
    
    677 685
            ; let (out_of_scope, other_holes, not_conc_errs, mult_co_errs)
    
    678 686
                     = partition_errors tidy_errs
    
    679 687
     
    
    680
    -               -- Don't suppress out-of-scope errors
    
    681
    -               -- See (SLIE0) in Note [cec_suppress: suppressing less-important error messages]
    
    682
    ---              ctxt_for_scope_errs = ctxt { cec_suppress = False }
    
    683
    -
    
    684 688
              -- First, deal with any out-of-scope errors:
    
    685
    -       ; (_, no_out_of_scope) <- askNoErrs $
    
    686
    -                                 reportHoles ctxt tidy_items out_of_scope
    
    689
    +       ; (_, out_of_scope_errs) <- askErrsFound $
    
    690
    +                                   reportHoles ctxt tidy_items out_of_scope
    
    687 691
     
    
    688 692
            -- Don't suppress holes or concreteness errors, ever
    
    689 693
            ; reportHoles ctxt tidy_items other_holes
    
    ... ... @@ -702,42 +706,49 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    702 706
            -- or   Int ~ t a  (AppTy on one side)
    
    703 707
            --
    
    704 708
            -- First visible ones, then invisible ones; but all serious
    
    705
    -       ; let suppress_insols = not no_out_of_scope
    
    706
    -                -- Serious errors are not suppressed by cec_suppress,
    
    707
    -                -- hence not including cec_suppress in suppress_insols
    
    708
    -                -- See (SLIE0) in Note [cec_suppress: suppressing less-important
    
    709
    -                --             error messages]
    
    709
    +       ; let suppress_insols = out_of_scope_errs
    
    710
    +                -- Serious errors are not suppressed by cec_outer_err,
    
    711
    +                -- hence not including cec_outer_err in suppress_insols
    
    712
    +                -- See (SLIE0) in Note [cec_outer_err: suppressing less-important
    
    713
    +                --                      error messages]
    
    710 714
                  (vis_items, invis_items)
    
    711 715
                     = partition (isVisibleOrigin . errorItemOrigin) tidy_items
    
    712 716
     
    
    713
    -       ; (vis_items1, no_vis_serious_errs)
    
    714
    -            <- askNoErrs $
    
    717
    +       ; (vis_items1, vis_serious_errs)
    
    718
    +            <- askErrsFound $
    
    715 719
                    tryReporters ctxt suppress_insols serious_reporters vis_items
    
    716 720
     
    
    717
    -       ; let suppress_invis = suppress_insols || not no_vis_serious_errs
    
    718
    -       ; (invis_items1, no_invis_serious_errs)
    
    719
    -            <- askNoErrs $
    
    721
    +       ; let suppress_invis = suppress_insols || vis_serious_errs
    
    722
    +       ; (invis_items1, invis_serious_errs)
    
    723
    +            <- askErrsFound $
    
    720 724
                    tryReporters ctxt suppress_invis serious_reporters invis_items
    
    721 725
     
    
    722
    -       -- Now take account of the inherited cec_suppress, and augment it
    
    726
    +       -- Now take account of the inherited cec_outer_err, and augment it
    
    723 727
            -- to suppress further errors if we have found any serious errors locally
    
    724
    -       ; let suppress_rest = cec_suppress ctxt
    
    728
    +       ; let suppress_implics = cec_outer_err ctxt
    
    725 729
                                  || suppress_invis
    
    726
    -                             || not no_invis_serious_errs
    
    727
    -
    
    728
    -       -- Next, deal with the less-serious constraints
    
    730
    +                             || invis_serious_errs
    
    731
    +             ctxt_for_implics = ctxt { cec_outer_err = suppress_implics }
    
    732
    +             (insol_implics, other_implics) = partitionBag insolubleImplic implics
    
    733
    +
    
    734
    +       -- Next, deal with the insoluble implications
    
    735
    +       ; (_, implic_errs)
    
    736
    +            <- askErrsFound $ mapBagM_ (reportImplic ctxt_for_implics) insol_implics
    
    737
    +
    
    738
    +       -- Finally, deal with the less-serious constraints,
    
    739
    +       -- both local and implications
    
    740
    +       -- suppressing if any errors have been reported so far
    
    741
    +       ; let suppress_rest = suppress_implics || implic_errs
    
    742
    +             ctxt_for_rest = ctxt { cec_outer_err = suppress_rest }
    
    729 743
            ; leftovers <- tryReporters ctxt suppress_rest less_serious_reporters $
    
    730 744
                           (vis_items1 ++ invis_items1)
    
    745
    +       ; mapBagM_ (reportImplic ctxt_for_rest) other_implics
    
    746
    +
    
    747
    +       -- Check that we have covered all the constraints
    
    731 748
            ; massertPpr (null leftovers)
    
    732 749
                (text "The following unsolved Wanted constraints \
    
    733 750
                      \have not been reported to the user:"
    
    734 751
                $$ ppr leftovers)
    
    735
    -
    
    736
    -       ; let ctxt_for_rest = ctxt { cec_suppress = suppress_rest }
    
    737
    -       ; mapBagM_ (reportImplic ctxt_for_rest) implics
    
    738
    -            -- NB ctxt2: don't suppress inner insolubles if there's only a
    
    739
    -            -- wanted insoluble here; but do suppress inner insolubles
    
    740
    -            -- if there's a *given* insoluble here (= inaccessible code)
    
    741 752
            }
    
    742 753
      where
    
    743 754
         env       = cec_tidy ctxt
    
    ... ... @@ -758,7 +769,7 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    758 769
               DE_Multiplicity mult_co loc
    
    759 770
                 -> (es1, es2, es3, (mult_co, loc):es4)
    
    760 771
     
    
    761
    -    --serious_reporters: ones that should *not* be suppressed by cec_suppress,
    
    772
    +    --serious_reporters: ones that should *not* be suppressed by cec_outer_err,
    
    762 773
         --     (i.e. by an insoluble somewhere else in the tree)
    
    763 774
         serious_reporters
    
    764 775
           = [ -- We put implicit lifting errors first, because are solid errors
    
    ... ... @@ -1054,7 +1065,7 @@ reportHoles :: SolverReportErrCtxt
    1054 1065
                 -> [ErrorItem]  -- Other (tidied) constraints
    
    1055 1066
                 -> [Hole]       -- Holes to report
    
    1056 1067
                 -> TcM ()
    
    1057
    --- Ignores cec_suppress
    
    1068
    +-- Ignores cec_outer_err
    
    1058 1069
     reportHoles ctxt tidy_items holes
    
    1059 1070
       = do
    
    1060 1071
           diag_opts <- initDiagOpts <$> getDynFlags
    
    ... ... @@ -1110,7 +1121,7 @@ zonkTidyTcLclEnvs tidy_env lcls = foldM go (tidy_env, emptyNameEnv) (concatMap c
    1110 1121
                     return (tidy_env',  extendNameEnv name_env name tidy_ty)
    
    1111 1122
     
    
    1112 1123
     reportNotConcreteErrs :: SolverReportErrCtxt -> [NotConcreteError] -> TcM ()
    
    1113
    --- Ignores cec_suppress
    
    1124
    +-- Ignores cec_outer_err
    
    1114 1125
     reportNotConcreteErrs _ [] = return ()
    
    1115 1126
     reportNotConcreteErrs ctxt errs@(err0:_)
    
    1116 1127
       = do { msg <- mkErrorReport (ctLocEnv (nce_loc err0)) diag (Just ctxt) [] []
    
    ... ... @@ -1311,7 +1322,7 @@ reportGroup mk_err ctxt items
    1311 1322
            ; err <- mk_err items
    
    1312 1323
            ; traceTc "About to maybeReportErr" $
    
    1313 1324
              vcat [ text "Constraint:"             <+> ppr items
    
    1314
    -              , text "cec_suppress ="          <+> ppr (cec_suppress ctxt)
    
    1325
    +              , text "cec_outer_err ="         <+> ppr (cec_outer_err ctxt)
    
    1315 1326
                   , text "cec_defer_type_errors =" <+> ppr (cec_defer_type_errors ctxt) ]
    
    1316 1327
     
    
    1317 1328
            ; maybeReportError ctxt items err
    
    ... ... @@ -1360,9 +1371,9 @@ maybeReportError ctxt items@(item1:|_) (SolverReport { sr_important_msg = import
    1360 1371
     --    T @X1 T1 ~ T @X2 T2   gives two insolubles: X1~X2 and T1~T2 (KindVType, T17380, T22332b)
    
    1361 1372
     --
    
    1362 1373
     --     | any ei_insoluble items
    
    1363
    ---     = False  -- Don't suppress insolubles even if cec_suppress is True
    
    1374
    +--     = False  -- Don't suppress insolubles even if cec_outer_err is True
    
    1364 1375
     
    
    1365
    -     | cec_suppress ctxt
    
    1376
    +     | cec_outer_err ctxt
    
    1366 1377
          = True   -- Some earlier error has occurred, so suppress this diagnostic
    
    1367 1378
     
    
    1368 1379
          | all ei_suppress items
    
    ... ... @@ -1431,7 +1442,7 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
    1431 1442
     
    
    1432 1443
     tryReporters :: SolverReportErrCtxt
    
    1433 1444
                  -> Bool              -- Suppress errors if this is True
    
    1434
    -                                  -- (over-riding cec_suppress)
    
    1445
    +                                  -- (over-riding cec_outer_err)
    
    1435 1446
                  -> [ReporterSpec]
    
    1436 1447
                  -> [ErrorItem]
    
    1437 1448
                  -> TcM [ErrorItem]
    
    ... ... @@ -1442,8 +1453,8 @@ tryReporters ctxt suppress reporters items
    1442 1453
            ; traceTc "tryReporters }" (ppr items')
    
    1443 1454
            ; return items' }
    
    1444 1455
       where
    
    1445
    -    -- Use `suppress` to set the `cec_supress` flag for these items
    
    1446
    -    ctxt_w_suppress = ctxt { cec_suppress = suppress }
    
    1456
    +    -- Use `suppress` to set the `cec_outer_err` flag for these items
    
    1457
    +    ctxt_w_suppress = ctxt { cec_outer_err = suppress }
    
    1447 1458
         go []     items = return items
    
    1448 1459
         go (r:rs) items = do { items' <- tryReporter ctxt_w_suppress r items
    
    1449 1460
                              ; go rs items' }
    
    ... ... @@ -1490,7 +1501,7 @@ mkErrorReport tcl_env msg mb_ctxt supp hints
    1490 1501
     {- Note [Always warn with -fdefer-type-errors]
    
    1491 1502
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    1492 1503
     When -fdefer-type-errors is on we warn about *all* type errors, even
    
    1493
    -if cec_suppress is on.  This can lead to a lot more warnings than you
    
    1504
    +if cec_outer_err is on.  This can lead to a lot more warnings than you
    
    1494 1505
     would get errors without -fdefer-type-errors, but if we suppress any of
    
    1495 1506
     them you might get a runtime error that wasn't warned about at compile
    
    1496 1507
     time.
    
    ... ... @@ -1550,8 +1561,8 @@ mkIrredErr ctxt items
    1550 1561
     
    
    1551 1562
     {- Note [Constructing Hole Errors]
    
    1552 1563
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    1553
    -Whether or not 'mkHoleError' returns an error is not influenced by cec_suppress. In other terms,
    
    1554
    -these "hole" errors are /not/ suppressed by cec_suppress. We want to see them!
    
    1564
    +Whether or not 'mkHoleError' returns an error is not influenced by cec_outer_err. In other terms,
    
    1565
    +these "hole" errors are /not/ suppressed by cec_outer_err. We want to see them!
    
    1555 1566
     
    
    1556 1567
     There are two cases to consider:
    
    1557 1568
     
    

  • compiler/GHC/Tc/Errors/Ppr.hs
    ... ... @@ -4085,7 +4085,7 @@ instance Outputable SolverReportErrCtxt where
    4085 4085
                , cec_out_of_scope_holes = osh
    
    4086 4086
                , cec_warn_redundant     = wr
    
    4087 4087
                , cec_expand_syns        = es
    
    4088
    -           , cec_suppress           = sup })
    
    4088
    +           , cec_outer_err          = sup })
    
    4089 4089
         = text "CEC" <+> braces (vcat
    
    4090 4090
              [ text "cec_binds"              <+> equals <+> ppr bvar
    
    4091 4091
              , text "cec_defer_type_errors"  <+> equals <+> ppr dte
    
    ... ... @@ -4094,7 +4094,7 @@ instance Outputable SolverReportErrCtxt where
    4094 4094
              , text "cec_out_of_scope_holes" <+> equals <+> ppr osh
    
    4095 4095
              , text "cec_warn_redundant"     <+> equals <+> ppr wr
    
    4096 4096
              , text "cec_expand_syns"        <+> equals <+> ppr es
    
    4097
    -         , text "cec_suppress"           <+> equals <+> ppr sup ])
    
    4097
    +         , text "cec_outer_err"          <+> equals <+> ppr sup ])
    
    4098 4098
     
    
    4099 4099
     {- *********************************************************************
    
    4100 4100
     *                                                                      *
    

  • compiler/GHC/Tc/Errors/Types.hs
    ... ... @@ -5474,10 +5474,10 @@ data SolverReportErrCtxt
    5474 5474
               , cec_warn_redundant :: Bool    -- ^ True <=> -Wredundant-constraints
    
    5475 5475
               , cec_expand_syns    :: Bool    -- ^ True <=> -fprint-expanded-synonyms
    
    5476 5476
     
    
    5477
    -          , cec_suppress :: Bool    -- ^ True <=> More important errors have occurred,
    
    5477
    +          , cec_outer_err :: Bool   -- ^ True <=> More important errors have been reported
    
    5478 5478
                                         --            so create bindings if need be, but
    
    5479 5479
                                         --            don't issue any more errors/warnings
    
    5480
    -                -- See Note [cec_suppress: suppressing less-important error messages]
    
    5480
    +                -- See Note [cec_outer_err: suppressing less-important error messages]
    
    5481 5481
           }
    
    5482 5482
     
    
    5483 5483
     ----------------------------------------------------------------------------
    
    ... ... @@ -5508,9 +5508,7 @@ data ErrorItem
    5508 5508
            , ei_insoluble :: Bool   -- True if the constraint is definitely insoluble
    
    5509 5509
                                     -- Cache of `insolubleCt`
    
    5510 5510
     
    
    5511
    -       , ei_suppress  :: Bool   -- Suppress because of
    
    5512
    -                                -- Note [Wanteds rewrite Wanteds: rewriter-sets]
    
    5513
    -                                -- in GHC.Tc.Constraint
    
    5511
    +       , ei_suppress  :: Bool   -- See Note [ei_suppress: suppressing confusing errors]
    
    5514 5512
            }
    
    5515 5513
     
    
    5516 5514
     instance Outputable ErrorItem where
    

  • compiler/GHC/Tc/Instance/Family.hs
    ... ... @@ -618,16 +618,16 @@ addLocalFamInst (home_fie, my_fis) fam_inst
    618 618
                  home_fie' = extendFamInstEnv home_fie fam_inst
    
    619 619
     
    
    620 620
                -- Check for conflicting instance decls and injectivity violations
    
    621
    -       ; ((), no_errs) <- askNoErrs $
    
    621
    +       ; ((), has_errs) <- askErrsFound $
    
    622 622
              do { checkForConflicts            inst_envs fam_inst
    
    623 623
                 ; checkForInjectivityConflicts inst_envs fam_inst
    
    624 624
                 ; checkInjectiveEquation       fam_inst
    
    625 625
                 }
    
    626 626
     
    
    627
    -       ; if no_errs then
    
    628
    -            return (home_fie', fam_inst : my_fis)
    
    627
    +       ; if has_errs then
    
    628
    +            return (home_fie,  my_fis)
    
    629 629
              else
    
    630
    -            return (home_fie,  my_fis) }
    
    630
    +            return (home_fie', fam_inst : my_fis) }
    
    631 631
     
    
    632 632
     {-
    
    633 633
     ************************************************************************
    

  • compiler/GHC/Tc/Solver/Default.hs
    ... ... @@ -998,7 +998,8 @@ last example above.
    998 998
     
    
    999 999
     tryTypeClassDefaulting :: WantedConstraints -> TcS WantedConstraints
    
    1000 1000
     tryTypeClassDefaulting wc
    
    1001
    -  | isEmptyWC wc || insolubleWC wc -- See Note [Defaulting insolubles]
    
    1001
    +  | isEmptyWC wc
    
    1002
    +    -- || insolubleWC wc -- See Note [Defaulting insolubles]
    
    1002 1003
       = return wc
    
    1003 1004
       | otherwise  -- See Note [When to do type-class defaulting]
    
    1004 1005
       = do { something_happened <- applyDefaultingRules wc
    

  • compiler/GHC/Tc/Types/Constraint.hs
    ... ... @@ -1881,16 +1881,19 @@ approximateWCX include_non_quantifiable wc
    1881 1881
     
    
    1882 1882
         float_implic :: Bool -> TcTyCoVarSet -> Implication
    
    1883 1883
                      -> ApproxWC -> ApproxWC
    
    1884
    -    float_implic encl_eqs trapping_tvs imp
    
    1885
    -      = float_wc new_encl_eqs new_trapping_tvs (ic_wanted imp)
    
    1884
    +    float_implic encl_eqs trapping_tvs
    
    1885
    +        (Implic { ic_wanted = wc, ic_given_eqs = given_eqs
    
    1886
    +                , ic_skols = skols, ic_status = status }) acc
    
    1887
    +      | isInsolubleStatus status = acc
    
    1888
    +      | otherwise                = float_wc new_encl_eqs new_trapping_tvs wc acc
    
    1886 1889
           where
    
    1887
    -        new_trapping_tvs = trapping_tvs `extendVarSetList` ic_skols imp
    
    1888
    -        new_encl_eqs = encl_eqs || ic_given_eqs imp == MaybeGivenEqs
    
    1890
    +        new_trapping_tvs = trapping_tvs `extendVarSetList` skols
    
    1891
    +        new_encl_eqs = encl_eqs || given_eqs == MaybeGivenEqs
    
    1889 1892
     
    
    1890 1893
         float_ct :: Bool -> TcTyCoVarSet -> Ct
    
    1891 1894
                  -> ApproxWC -> ApproxWC
    
    1892 1895
         float_ct encl_eqs skol_tvs ct acc@(quant, no_quant)
    
    1893
    -       | isGivenCt ct                                = acc
    
    1896
    +       | isGivenCt ct                         = acc
    
    1894 1897
                -- There can be (insoluble) Given constraints in wc_simple,
    
    1895 1898
                -- there so that we get error reports for unreachable code
    
    1896 1899
                -- See `given_insols` in GHC.Tc.Solver.Solve.solveImplication
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -82,7 +82,7 @@ module GHC.Tc.Utils.Monad(
    82 82
       -- * Shared error message stuff: renamer and typechecker
    
    83 83
       recoverM, mapAndRecoverM, mapAndReportM, foldAndRecoverM,
    
    84 84
       attemptM, tryTc,
    
    85
    -  askNoErrs, discardErrs,
    
    85
    +  askErrsFound, discardErrs,
    
    86 86
       tryTcDiscardingErrs,
    
    87 87
       tryTcDiscardingErrs',
    
    88 88
       checkNoErrs, whenNoErrs,
    
    ... ... @@ -1443,8 +1443,8 @@ checkNoErrs :: TcM r -> TcM r
    1443 1443
     --      If so, it fails too.
    
    1444 1444
     -- Regardless, any errors generated by m are propagated to the enclosing context.
    
    1445 1445
     checkNoErrs main
    
    1446
    -  = do  { (res, no_errs) <- askNoErrs main
    
    1447
    -        ; unless no_errs failM
    
    1446
    +  = do  { (res, errs_found) <- askErrsFound main
    
    1447
    +        ; when errs_found failM
    
    1448 1448
             ; return res }
    
    1449 1449
     
    
    1450 1450
     -----------------------
    
    ... ... @@ -1630,19 +1630,19 @@ capture_messages thing_inside
    1630 1630
            ; return (res, msgs) }
    
    1631 1631
     
    
    1632 1632
     -----------------------
    
    1633
    --- (askNoErrs m) runs m
    
    1633
    +-- (askErrsFound m) runs m
    
    1634 1634
     -- If m fails,
    
    1635
    ---    then (askNoErrs m) fails, propagating only
    
    1635
    +--    then (askErrsFound m) fails, propagating only
    
    1636 1636
     --         insoluble constraints
    
    1637 1637
     --
    
    1638 1638
     -- If m succeeds with result r,
    
    1639
    ---    then (askNoErrs m) succeeds with result (r, b),
    
    1640
    ---         where b is True iff m generated no errors
    
    1639
    +--    then (askErrsFound m) succeeds with result (r, b),
    
    1640
    +--         where b is True iff m generated errors
    
    1641 1641
     --
    
    1642 1642
     -- Regardless of success or failure,
    
    1643 1643
     --   propagate any errors/warnings generated by m
    
    1644
    -askNoErrs :: TcRn a -> TcRn (a, Bool)
    
    1645
    -askNoErrs thing_inside
    
    1644
    +askErrsFound :: TcRn a -> TcRn (a, Bool)
    
    1645
    +askErrsFound thing_inside
    
    1646 1646
       = do { ((mb_res, lie), msgs) <- capture_messages    $
    
    1647 1647
                                       capture_constraints $
    
    1648 1648
                                       tcTryM thing_inside
    
    ... ... @@ -1655,7 +1655,7 @@ askNoErrs thing_inside
    1655 1655
                Just res -> do { emitConstraints lie
    
    1656 1656
                               ; let errs_found = errorsFound msgs
    
    1657 1657
                                               || insolubleWC lie
    
    1658
    -                          ; return (res, not errs_found) } }
    
    1658
    +                          ; return (res, errs_found) } }
    
    1659 1659
     
    
    1660 1660
     -----------------------
    
    1661 1661
     tryCaptureConstraints :: TcM a -> TcM (Maybe a, WantedConstraints)