| ... |
... |
@@ -481,7 +481,8 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs |
|
481
|
481
|
ctxt' = ctxt1 { cec_tidy = env1
|
|
482
|
482
|
, cec_encl = implic' : cec_encl ctxt
|
|
483
|
483
|
|
|
484
|
|
- , cec_suppress = insoluble || cec_suppress ctxt
|
|
|
484
|
+-- NO LONGER NEEDED
|
|
|
485
|
+-- , cec_suppress = cec_suppress ctxt
|
|
485
|
486
|
-- Suppress inessential errors if there
|
|
486
|
487
|
-- are insolubles anywhere in the
|
|
487
|
488
|
-- tree rooted here, or we've come across
|
| ... |
... |
@@ -572,8 +573,9 @@ mkErrorItem ct |
|
572
|
573
|
, ei_suppress = suppressCtError ev }}
|
|
573
|
574
|
|
|
574
|
575
|
-- | Actually report this 'ErrorItem'.
|
|
575
|
|
-unsuppressErrorItem :: ErrorItem -> ErrorItem
|
|
576
|
|
-unsuppressErrorItem ei = ei { ei_suppress = False }
|
|
|
576
|
+-- NOT NEEDED ANY MORE
|
|
|
577
|
+--unsuppressErrorItem :: ErrorItem -> ErrorItem
|
|
|
578
|
+-- unsuppressErrorItem ei = ei { ei_suppress = False }
|
|
577
|
579
|
|
|
578
|
580
|
-- | Should we completely ignore this constraint in error reporting?
|
|
579
|
581
|
-- It *must* be the case that any constraint for which this returns True
|
| ... |
... |
@@ -647,19 +649,23 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
647
|
649
|
| isEmptyWC wc
|
|
648
|
650
|
= traceTc "reportWanteds empty WC" empty
|
|
649
|
651
|
| otherwise
|
|
650
|
|
- = do { tidy_items1 <- mapMaybeM mkErrorItem tidy_cts
|
|
|
652
|
+ = do { let tidy_cts = bagToList (mapBag (tidyCt env) simples)
|
|
|
653
|
+ tidy_errs = bagToList (mapBag (tidyDelayedError env) errs)
|
|
|
654
|
+
|
|
|
655
|
+ ; tidy_items1 <- mapMaybeM mkErrorItem tidy_cts
|
|
651
|
656
|
|
|
652
|
657
|
-- Catch an awkward (and probably rare) case in which /all/ errors are
|
|
653
|
658
|
-- suppressed: see (SCE3) in Note [ei_suppress: suppressing confusing errors]
|
|
654
|
|
- ; errs_already <- ifErrsM (return True) (return False)
|
|
|
659
|
+-- ; errs_already <- ifErrsM (return True) (return False)
|
|
655
|
660
|
; let tidy_items
|
|
656
|
|
- | not errs_already -- Have not already reported an error (perhaps
|
|
657
|
|
- -- from an outer implication); see #21405
|
|
658
|
|
- , not (any ignoreConstraint simples) -- No error is ignorable (is reported elsewhere)
|
|
659
|
|
- , all ei_suppress tidy_items1 -- All errors are suppressed
|
|
660
|
|
- = map unsuppressErrorItem tidy_items1
|
|
661
|
|
-
|
|
662
|
|
- | otherwise
|
|
|
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
|
|
663
|
669
|
= tidy_items1
|
|
664
|
670
|
|
|
665
|
671
|
; traceTc "reportWanteds 1" (vcat [ text "Simples =" <+> ppr simples
|
| ... |
... |
@@ -668,23 +674,20 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
668
|
674
|
, text "tidy_items1 =" <+> ppr tidy_items1
|
|
669
|
675
|
, text "tidy_errs =" <+> ppr tidy_errs ])
|
|
670
|
676
|
|
|
671
|
|
- -- First, deal with any out-of-scope errors:
|
|
672
|
|
- ; let (out_of_scope, other_holes, not_conc_errs, mult_co_errs) = partition_errors tidy_errs
|
|
|
677
|
+ ; let (out_of_scope, other_holes, not_conc_errs, mult_co_errs)
|
|
|
678
|
+ = partition_errors tidy_errs
|
|
|
679
|
+
|
|
673
|
680
|
-- Don't suppress out-of-scope errors
|
|
674
|
681
|
-- See (SLIE0) in Note [cec_suppress: suppressing less-important error messages]
|
|
675
|
|
- ctxt_for_scope_errs = ctxt { cec_suppress = False }
|
|
676
|
|
- ; (_, no_out_of_scope) <- askNoErrs $
|
|
677
|
|
- reportHoles tidy_items ctxt_for_scope_errs out_of_scope
|
|
|
682
|
+-- ctxt_for_scope_errs = ctxt { cec_suppress = False }
|
|
678
|
683
|
|
|
679
|
|
- -- Next, deal with things that are utterly wrong
|
|
680
|
|
- -- These should not be suppressed by the incoming context
|
|
681
|
|
- -- (but should be suppressed by out-of-scope errors)
|
|
682
|
|
- -- See (SLIE0) in Note [cec_suppress: suppressing less-important error messages]
|
|
683
|
|
- ; let ctxt_for_insols = ctxt { cec_suppress = not no_out_of_scope }
|
|
|
684
|
+ -- First, deal with any out-of-scope errors:
|
|
|
685
|
+ ; (_, no_out_of_scope) <- askNoErrs $
|
|
|
686
|
+ reportHoles ctxt tidy_items out_of_scope
|
|
684
|
687
|
|
|
685
|
|
- -- Don't suppress holes or concreteness errors unless we have scope errors
|
|
686
|
|
- ; reportHoles tidy_items ctxt_for_insols other_holes
|
|
687
|
|
- ; reportNotConcreteErrs ctxt_for_insols not_conc_errs
|
|
|
688
|
+ -- Don't suppress holes or concreteness errors, ever
|
|
|
689
|
+ ; reportHoles ctxt tidy_items other_holes
|
|
|
690
|
+ ; reportNotConcreteErrs ctxt not_conc_errs
|
|
688
|
691
|
|
|
689
|
692
|
-- We only want to report multiplicity coercion errors for multiplicity
|
|
690
|
693
|
-- constraints which are /solved/ with a non-reflexivity coercion. We
|
| ... |
... |
@@ -692,29 +695,45 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
692
|
695
|
-- when /all/ other constraints are solved.
|
|
693
|
696
|
-- See wrinkle (DME1) in Note [Coercion errors in tcSubMult] in GHC.Tc.Utils.Unify.
|
|
694
|
697
|
; when (null simples) $
|
|
695
|
|
- reportMultiplicityCoercionErrs ctxt_for_insols mult_co_errs
|
|
|
698
|
+ reportMultiplicityCoercionErrs ctxt mult_co_errs
|
|
696
|
699
|
|
|
697
|
700
|
-- Now the constraints that give serious errors
|
|
698
|
701
|
-- Like Int ~ Bool (incl nullary TyCons)
|
|
699
|
702
|
-- or Int ~ t a (AppTy on one side)
|
|
700
|
|
- ; (items1, no_serious_errs)
|
|
|
703
|
+ --
|
|
|
704
|
+ -- 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]
|
|
|
710
|
+ (vis_items, invis_items)
|
|
|
711
|
+ = partition (isVisibleOrigin . errorItemOrigin) tidy_items
|
|
|
712
|
+
|
|
|
713
|
+ ; (vis_items1, no_vis_serious_errs)
|
|
701
|
714
|
<- askNoErrs $
|
|
702
|
|
- tryReporters ctxt_for_insols serious_reporters tidy_items
|
|
|
715
|
+ tryReporters ctxt suppress_insols serious_reporters vis_items
|
|
|
716
|
+
|
|
|
717
|
+ ; let suppress_invis = suppress_insols || not no_vis_serious_errs
|
|
|
718
|
+ ; (invis_items1, no_invis_serious_errs)
|
|
|
719
|
+ <- askNoErrs $
|
|
|
720
|
+ tryReporters ctxt suppress_invis serious_reporters invis_items
|
|
703
|
721
|
|
|
704
|
722
|
-- Now take account of the inherited cec_suppress, and augment it
|
|
705
|
723
|
-- to suppress further errors if we have found any serious errors locally
|
|
706
|
|
- ; let suppress_for_rest = cec_suppress ctxt
|
|
707
|
|
- || not no_out_of_scope
|
|
708
|
|
- || not no_serious_errs
|
|
709
|
|
- ctxt_for_rest = ctxt { cec_suppress = suppress_for_rest }
|
|
|
724
|
+ ; let suppress_rest = cec_suppress ctxt
|
|
|
725
|
+ || suppress_invis
|
|
|
726
|
+ || not no_invis_serious_errs
|
|
710
|
727
|
|
|
711
|
728
|
-- Next, deal with the less-serious constraints
|
|
712
|
|
- ; leftovers <- tryReporters ctxt_for_rest less_serious_reporters items1
|
|
|
729
|
+ ; leftovers <- tryReporters ctxt suppress_rest less_serious_reporters $
|
|
|
730
|
+ (vis_items1 ++ invis_items1)
|
|
713
|
731
|
; massertPpr (null leftovers)
|
|
714
|
732
|
(text "The following unsolved Wanted constraints \
|
|
715
|
733
|
\have not been reported to the user:"
|
|
716
|
734
|
$$ ppr leftovers)
|
|
717
|
735
|
|
|
|
736
|
+ ; let ctxt_for_rest = ctxt { cec_suppress = suppress_rest }
|
|
718
|
737
|
; mapBagM_ (reportImplic ctxt_for_rest) implics
|
|
719
|
738
|
-- NB ctxt2: don't suppress inner insolubles if there's only a
|
|
720
|
739
|
-- wanted insoluble here; but do suppress inner insolubles
|
| ... |
... |
@@ -722,8 +741,6 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
722
|
741
|
}
|
|
723
|
742
|
where
|
|
724
|
743
|
env = cec_tidy ctxt
|
|
725
|
|
- tidy_cts = bagToList (mapBag (tidyCt env) simples)
|
|
726
|
|
- tidy_errs = bagToList (mapBag (tidyDelayedError env) errs)
|
|
727
|
744
|
|
|
728
|
745
|
partition_errors :: [DelayedError] -> ([Hole], [Hole], [NotConcreteError], [(TcCoercion, CtLoc)])
|
|
729
|
746
|
partition_errors []
|
| ... |
... |
@@ -747,14 +764,14 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
747
|
764
|
= [ -- We put implicit lifting errors first, because are solid errors
|
|
748
|
765
|
-- See "Implicit lifting" in GHC.Tc.Gen.Splice
|
|
749
|
766
|
-- Note [Lifecycle of an untyped splice, and PendingRnSplice]
|
|
750
|
|
- ("implicit lifting", is_implicit_lifting, True, mkImplicitLiftingReporter)
|
|
|
767
|
+ ("implicit lifting", is_implicit_lifting, mkImplicitLiftingReporter)
|
|
751
|
768
|
|
|
752
|
769
|
-- Next, solid equality errors
|
|
753
|
|
- , given_eq_spec
|
|
754
|
|
- , ("insoluble2", utterly_wrong, True, mkGroupReporter mkEqErr)
|
|
755
|
|
- , ("skolem eq1", very_wrong, True, mkSkolReporter)
|
|
756
|
|
- , ("FixedRuntimeRep", is_FRR, True, mkGroupReporter mkFRRErr)
|
|
757
|
|
- , ("skolem eq2", skolem_eq, True, mkSkolReporter)
|
|
|
770
|
+ , ("given_eq", is_given_eq, mkGivenErrorReporter)
|
|
|
771
|
+ , ("insoluble2", utterly_wrong, mkGroupReporter mkEqErr)
|
|
|
772
|
+ , ("skolem eq1", very_wrong, mkSkolReporter)
|
|
|
773
|
+ , ("FixedRuntimeRep", is_FRR, mkGroupReporter mkFRRErr)
|
|
|
774
|
+ , ("skolem eq2", skolem_eq, mkSkolReporter)
|
|
758
|
775
|
|
|
759
|
776
|
-- Next, custom type errors
|
|
760
|
777
|
-- See Note [Custom type errors in constraints] in GHC.Tc.Types.Constraint
|
| ... |
... |
@@ -770,29 +787,29 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
770
|
787
|
-- we want to report it as a custom error, /not/ as a mis-match
|
|
771
|
788
|
-- between TypeError and ()! Also see the Assert example
|
|
772
|
789
|
-- in Note [Custom type errors in constraints]
|
|
773
|
|
- , ("custom_error", is_user_type_error, True, mkUserTypeErrorReporter)
|
|
|
790
|
+ , ("custom_error", is_user_type_error, mkUserTypeErrorReporter)
|
|
774
|
791
|
-- (Handles TypeError and Unsatisfiable)
|
|
775
|
792
|
|
|
776
|
793
|
-- "non-tv-eq": equalities (ty1 ~ ty2) where ty1 is not a tyvar
|
|
777
|
|
- , ("non-tv eq", non_tv_eq, True, mkSkolReporter)
|
|
|
794
|
+ , ("non-tv eq", non_tv_eq, mkSkolReporter)
|
|
778
|
795
|
|
|
779
|
796
|
-- The only remaining equalities are alpha ~ ty,
|
|
780
|
797
|
-- where alpha is untouchable; and representational equalities
|
|
781
|
798
|
-- Prefer homogeneous equalities over hetero, because the
|
|
782
|
799
|
-- former might be holding up the latter.
|
|
783
|
800
|
-- See Note [Equalities with heterogeneous kinds] in GHC.Tc.Solver.Equality
|
|
784
|
|
- , ("Homo eqs", is_homo_equality, True, mkGroupReporter mkEqErr)
|
|
785
|
|
- , ("Other eqs", is_equality, True, mkGroupReporter mkEqErr)
|
|
|
801
|
+ , ("Homo eqs", is_homo_equality, mkGroupReporter mkEqErr)
|
|
|
802
|
+ , ("Other eqs", is_equality, mkGroupReporter mkEqErr)
|
|
786
|
803
|
|
|
787
|
|
- , ("Insoluble fundeps", is_insoluble, True, mkGroupReporter mkDictErr)
|
|
|
804
|
+ , ("Insoluble fundeps", is_insoluble, mkGroupReporter mkDictErr)
|
|
788
|
805
|
]
|
|
789
|
806
|
|
|
790
|
807
|
-- less_serious_reporters: we suppress these if have already
|
|
791
|
808
|
-- reported a serious error, higher in the tree
|
|
792
|
809
|
less_serious_reporters
|
|
793
|
|
- = [ ("Irreds", is_irred, False, mkGroupReporter mkIrredErr)
|
|
794
|
|
- , ("Dicts", is_dict, False, mkGroupReporter mkDictErr)
|
|
795
|
|
- , ("Quantified", is_qc, False, mkGroupReporter mkQCErr) ]
|
|
|
810
|
+ = [ ("Irreds", is_irred, mkGroupReporter mkIrredErr)
|
|
|
811
|
+ , ("Dicts", is_dict, mkGroupReporter mkDictErr)
|
|
|
812
|
+ , ("Quantified", is_qc, mkGroupReporter mkQCErr) ]
|
|
796
|
813
|
|
|
797
|
814
|
-- rigid_nom_eq, rigid_nom_tv_eq,
|
|
798
|
815
|
is_dict, is_equality, is_FRR, is_irred :: ErrorItem -> Pred -> Bool
|
| ... |
... |
@@ -857,30 +874,6 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics |
|
857
|
874
|
is_qc _ (ForAllPred {}) = True
|
|
858
|
875
|
is_qc _ _ = False
|
|
859
|
876
|
|
|
860
|
|
- given_eq_spec -- See Note [Given errors]
|
|
861
|
|
- | has_gadt_match_here
|
|
862
|
|
- = ("insoluble1a", is_given_eq, True, mkGivenErrorReporter)
|
|
863
|
|
- | otherwise
|
|
864
|
|
- = ("insoluble1b", is_given_eq, False, ignoreErrorReporter)
|
|
865
|
|
- -- False means don't suppress subsequent errors
|
|
866
|
|
- -- Reason: we don't report all given errors
|
|
867
|
|
- -- (see mkGivenErrorReporter), and we should only suppress
|
|
868
|
|
- -- subsequent errors if we actually report this one!
|
|
869
|
|
- -- #13446 is an example
|
|
870
|
|
-
|
|
871
|
|
- -- See Note [Given errors]
|
|
872
|
|
- has_gadt_match_here = has_gadt_match (cec_encl ctxt)
|
|
873
|
|
- has_gadt_match [] = False
|
|
874
|
|
- has_gadt_match (implic : implics)
|
|
875
|
|
- | PatSkol {} <- ic_info implic
|
|
876
|
|
- , ic_given_eqs implic /= NoGivenEqs
|
|
877
|
|
- , ic_warn_inaccessible implic
|
|
878
|
|
- -- Don't bother doing this if -Winaccessible-code isn't enabled.
|
|
879
|
|
- -- See Note [Avoid -Winaccessible-code when deriving] in GHC.Tc.TyCl.Instance.
|
|
880
|
|
- = True
|
|
881
|
|
- | otherwise
|
|
882
|
|
- = has_gadt_match implics
|
|
883
|
|
-
|
|
884
|
877
|
---------------
|
|
885
|
878
|
isSkolemTy :: TcLevel -> Type -> Bool
|
|
886
|
879
|
-- The type is a skolem tyvar
|
| ... |
... |
@@ -1039,7 +1032,6 @@ type Reporter |
|
1039
|
1032
|
type ReporterSpec
|
|
1040
|
1033
|
= ( String -- Name
|
|
1041
|
1034
|
, ErrorItem -> Pred -> Bool -- Pick these ones
|
|
1042
|
|
- , Bool -- True <=> suppress subsequent reporters
|
|
1043
|
1035
|
, Reporter) -- The reporter itself
|
|
1044
|
1036
|
|
|
1045
|
1037
|
mkSkolReporter :: Reporter
|
| ... |
... |
@@ -1058,9 +1050,12 @@ mkSkolReporter ctxt items |
|
1058
|
1050
|
| eq_lhs_type item1 item2 = True
|
|
1059
|
1051
|
| otherwise = False
|
|
1060
|
1052
|
|
|
1061
|
|
-reportHoles :: [ErrorItem] -- other (tidied) constraints
|
|
1062
|
|
- -> SolverReportErrCtxt -> [Hole] -> TcM ()
|
|
1063
|
|
-reportHoles tidy_items ctxt holes
|
|
|
1053
|
+reportHoles :: SolverReportErrCtxt
|
|
|
1054
|
+ -> [ErrorItem] -- Other (tidied) constraints
|
|
|
1055
|
+ -> [Hole] -- Holes to report
|
|
|
1056
|
+ -> TcM ()
|
|
|
1057
|
+-- Ignores cec_suppress
|
|
|
1058
|
+reportHoles ctxt tidy_items holes
|
|
1064
|
1059
|
= do
|
|
1065
|
1060
|
diag_opts <- initDiagOpts <$> getDynFlags
|
|
1066
|
1061
|
let severity = diagReasonSeverity diag_opts (cec_type_holes ctxt)
|
| ... |
... |
@@ -1115,6 +1110,7 @@ zonkTidyTcLclEnvs tidy_env lcls = foldM go (tidy_env, emptyNameEnv) (concatMap c |
|
1115
|
1110
|
return (tidy_env', extendNameEnv name_env name tidy_ty)
|
|
1116
|
1111
|
|
|
1117
|
1112
|
reportNotConcreteErrs :: SolverReportErrCtxt -> [NotConcreteError] -> TcM ()
|
|
|
1113
|
+-- Ignores cec_suppress
|
|
1118
|
1114
|
reportNotConcreteErrs _ [] = return ()
|
|
1119
|
1115
|
reportNotConcreteErrs ctxt errs@(err0:_)
|
|
1120
|
1116
|
= do { msg <- mkErrorReport (ctLocEnv (nce_loc err0)) diag (Just ctxt) [] []
|
| ... |
... |
@@ -1218,15 +1214,10 @@ mkImplicitLiftingReporter ctxt |
|
1218
|
1214
|
|
|
1219
|
1215
|
mkGivenErrorReporter :: Reporter
|
|
1220
|
1216
|
-- See Note [Given errors]
|
|
1221
|
|
-mkGivenErrorReporter ctxt (item:|_)
|
|
|
1217
|
+mkGivenErrorReporter ctxt items@(item:|_)
|
|
|
1218
|
+ | Just implic <- has_gadt_match (cec_encl ctxt)
|
|
1222
|
1219
|
= do { (ctxt, relevant_binds, item) <- relevantBindings True ctxt item
|
|
1223
|
|
- ; let implic =
|
|
1224
|
|
- case cec_encl ctxt of
|
|
1225
|
|
- -- cec_encl is always non-empty when mkGivenErrorReporter is called
|
|
1226
|
|
- outer_implic:_ -> outer_implic
|
|
1227
|
|
- _ -> pprPanic "mkGivenErrorReporter" (ppr item)
|
|
1228
|
|
-
|
|
1229
|
|
- loc' = setCtLocEnv (ei_loc item) (ic_env implic)
|
|
|
1220
|
+ ; let loc' = setCtLocEnv (ei_loc item) (ic_env implic)
|
|
1230
|
1221
|
item' = item { ei_loc = loc' }
|
|
1231
|
1222
|
-- For given constraints we overwrite the env (and hence src-loc)
|
|
1232
|
1223
|
-- with one from the immediately-enclosing implication.
|
| ... |
... |
@@ -1234,18 +1225,29 @@ mkGivenErrorReporter ctxt (item:|_) |
|
1234
|
1225
|
|
|
1235
|
1226
|
; eq_err_msg <- mkEqErr_help ctxt item' ty1 ty2
|
|
1236
|
1227
|
; let msg = TcRnInaccessibleCode implic (SolverReportWithCtxt ctxt eq_err_msg)
|
|
1237
|
|
- ; msg <- mkErrorReport (ctLocEnv loc') msg (Just ctxt) [SupplementaryBindings relevant_binds] []
|
|
|
1228
|
+ ; msg <- mkErrorReport (ctLocEnv loc') msg (Just ctxt)
|
|
|
1229
|
+ [SupplementaryBindings relevant_binds] []
|
|
1238
|
1230
|
; reportDiagnostic msg }
|
|
1239
|
|
- where
|
|
1240
|
|
- (ty1, ty2) = getEqPredTys (errorItemPred item)
|
|
1241
|
1231
|
|
|
1242
|
|
-ignoreErrorReporter :: Reporter
|
|
1243
|
|
--- Discard Given errors that don't come from
|
|
1244
|
|
--- a pattern match; maybe we should warn instead?
|
|
1245
|
|
-ignoreErrorReporter ctxt items
|
|
|
1232
|
+ | otherwise -- Discard Given errors that don't come from
|
|
|
1233
|
+ -- a pattern match; maybe we should warn instead?
|
|
1246
|
1234
|
= do { traceTc "mkGivenErrorReporter no" (ppr items $$ ppr (cec_encl ctxt))
|
|
1247
|
1235
|
; return () }
|
|
1248
|
1236
|
|
|
|
1237
|
+ where
|
|
|
1238
|
+ (ty1, ty2) = getEqPredTys (errorItemPred item)
|
|
|
1239
|
+
|
|
|
1240
|
+ has_gadt_match :: [Implication] -> Maybe Implication
|
|
|
1241
|
+ has_gadt_match [] = Nothing
|
|
|
1242
|
+ has_gadt_match (implic : implics)
|
|
|
1243
|
+ | PatSkol {} <- ic_info implic
|
|
|
1244
|
+ , ic_given_eqs implic /= NoGivenEqs
|
|
|
1245
|
+ , ic_warn_inaccessible implic
|
|
|
1246
|
+ -- Don't bother doing this if -Winaccessible-code isn't enabled.
|
|
|
1247
|
+ -- See Note [Avoid -Winaccessible-code when deriving] in GHC.Tc.TyCl.Instance.
|
|
|
1248
|
+ = Just implic
|
|
|
1249
|
+ | otherwise
|
|
|
1250
|
+ = has_gadt_match implics
|
|
1249
|
1251
|
|
|
1250
|
1252
|
{- Note [Given errors]
|
|
1251
|
1253
|
~~~~~~~~~~~~~~~~~~~~~~
|
| ... |
... |
@@ -1427,31 +1429,29 @@ mkErrorTerm ct_loc ty ctxt msg supp hints |
|
1427
|
1429
|
|
|
1428
|
1430
|
; return $ evDelayedError ty err_str }
|
|
1429
|
1431
|
|
|
1430
|
|
-tryReporters :: SolverReportErrCtxt -> [ReporterSpec] -> [ErrorItem]
|
|
|
1432
|
+tryReporters :: SolverReportErrCtxt
|
|
|
1433
|
+ -> Bool -- Suppress errors if this is True
|
|
|
1434
|
+ -- (over-riding cec_suppress)
|
|
|
1435
|
+ -> [ReporterSpec]
|
|
|
1436
|
+ -> [ErrorItem]
|
|
1431
|
1437
|
-> TcM [ErrorItem]
|
|
1432
|
1438
|
-- Use the first reporter in the list whose predicate says True
|
|
1433
|
|
-tryReporters ctxt reporters items
|
|
1434
|
|
- = do { let (vis_items, invis_items) = partition (isVisibleOrigin . errorItemOrigin) items
|
|
1435
|
|
- ; traceTc "tryReporters {" (ppr vis_items $$ ppr invis_items)
|
|
1436
|
|
- ; items' <- go reporters vis_items invis_items
|
|
|
1439
|
+tryReporters ctxt suppress reporters items
|
|
|
1440
|
+ = do { traceTc "tryReporters {" (ppr items)
|
|
|
1441
|
+ ; items' <- go reporters items
|
|
1437
|
1442
|
; traceTc "tryReporters }" (ppr items')
|
|
1438
|
1443
|
; return items' }
|
|
1439
|
1444
|
where
|
|
1440
|
|
- go [] vis_items invis_items
|
|
1441
|
|
- = return (vis_items ++ invis_items)
|
|
1442
|
|
-
|
|
1443
|
|
- go (r : rs) vis_items invis_items
|
|
1444
|
|
- -- Always look at *visible* Origins before invisible ones
|
|
1445
|
|
- -- this is the whole point of isVisibleOrigin
|
|
1446
|
|
- = do { vis_items' <- tryReporter ctxt r vis_items
|
|
1447
|
|
- ; invis_items' <- tryReporter ctxt r invis_items
|
|
1448
|
|
- ; go rs vis_items' invis_items' }
|
|
1449
|
|
- -- Carry on with the rest, because we must make
|
|
1450
|
|
- -- deferred bindings for them if we have -fdefer-type-errors
|
|
1451
|
|
- -- But suppress their error messages
|
|
|
1445
|
+ -- Use `suppress` to set the `cec_supress` flag for these items
|
|
|
1446
|
+ ctxt_w_suppress = ctxt { cec_suppress = suppress }
|
|
|
1447
|
+ go [] items = return items
|
|
|
1448
|
+ go (r:rs) items = do { items' <- tryReporter ctxt_w_suppress r items
|
|
|
1449
|
+ ; go rs items' }
|
|
|
1450
|
+ -- Carry on with the rest, because we must make
|
|
|
1451
|
+ -- deferred bindings for them if we have -fdefer-type-errors
|
|
1452
|
1452
|
|
|
1453
|
1453
|
tryReporter :: SolverReportErrCtxt -> ReporterSpec -> [ErrorItem] -> TcM [ErrorItem]
|
|
1454
|
|
-tryReporter ctxt (str, keep_me, _, reporter) items = case nonEmpty yeses of
|
|
|
1454
|
+tryReporter ctxt (str, keep_me, reporter) items = case nonEmpty yeses of
|
|
1455
|
1455
|
Nothing -> return items
|
|
1456
|
1456
|
Just yeses -> do
|
|
1457
|
1457
|
{ traceTc "tryReporter{ " (text str <+> ppr yeses)
|