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

Commits:

18 changed files:

Changes:

  • compiler/GHC/Builtin/WiredIn/Ids.hs
    ... ... @@ -600,8 +600,8 @@ Wrinkles
    600 600
     (W1) Sometimes case (2) above needs to apply `noinline` to a type of kind
    
    601 601
          Constraint; e.g.
    
    602 602
                         noinline @(Eq Int) $dfEqInt
    
    603
    -     We don't have type-or-kind polymorphism, so we simply have two `inline`
    
    604
    -     Ids, namely `noinlineId` and `noinlineConstraintId`.
    
    603
    +     We don't have type-or-constraint polymorphism, so we simply have two
    
    604
    +     `inline` Ids, namely `noinlineId` and `noinlineConstraintId`.
    
    605 605
     
    
    606 606
     (W2) Note that noinline as currently implemented can hide some simplifications
    
    607 607
          since it hides strictness from the demand analyser. Specifically, the
    

  • compiler/GHC/Tc/Errors.hs
    ... ... @@ -711,35 +711,30 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    711 711
                  (vis_items, invis_items)
    
    712 712
                     = partition (isVisibleOrigin . errorItemOrigin) tidy_items
    
    713 713
     
    
    714
    -       ; (vis_items1, vis_serious_errs)
    
    715
    -            <- askErrsFound $
    
    716
    -               tryReporters ctxt suppress_insols serious_reporters vis_items
    
    717
    -
    
    718
    -       ; let suppress_invis = suppress_insols || vis_serious_errs
    
    719
    -       ; (invis_items1, invis_serious_errs)
    
    720
    -            <- askErrsFound $
    
    721
    -               tryReporters ctxt suppress_invis serious_reporters invis_items
    
    714
    +       ; (vis_items1, suppress_invis)    <- tryReporters ctxt serious_reporters
    
    715
    +                                                         (vis_items, suppress_insols)
    
    716
    +       ; (invis_items1, suppress_others) <- tryReporters ctxt serious_reporters
    
    717
    +                                                         (invis_items, suppress_invis)
    
    722 718
     
    
    723 719
            -- Now take account of the inherited cec_error_reported, and augment it
    
    724 720
            -- to suppress further errors if we have found any serious errors locally
    
    725 721
            -- See (SLIE2) in Note Note [cec_error_reported: suppressing less-serious errors]
    
    726 722
            ; let suppress_implics = cec_error_reported ctxt
    
    727
    -                             || suppress_invis
    
    728
    -                             || invis_serious_errs
    
    723
    +                             || suppress_others
    
    729 724
                  ctxt_for_implics = ctxt { cec_error_reported = suppress_implics }
    
    730 725
                  (insol_implics, other_implics) = partitionBag insolubleImplic implics
    
    731 726
     
    
    732 727
            -- Next, deal with the insoluble implications
    
    733
    -       ; (_, implic_errs)
    
    734
    -            <- askErrsFound $ mapBagM_ (reportImplic ctxt_for_implics) insol_implics
    
    728
    +       ; (_, implic_errs) <- askErrsFound $
    
    729
    +                              mapBagM_ (reportImplic ctxt_for_implics) insol_implics
    
    735 730
     
    
    736 731
            -- Finally, deal with the less-serious constraints,
    
    737 732
            -- both local and implications
    
    738 733
            -- suppressing if any errors have been reported so far
    
    739 734
            ; let suppress_rest = suppress_implics || implic_errs
    
    740 735
                  ctxt_for_rest = ctxt { cec_error_reported = suppress_rest }
    
    741
    -       ; leftovers <- tryReporters ctxt suppress_rest less_serious_reporters $
    
    742
    -                      (vis_items1 ++ invis_items1)
    
    736
    +       ; (leftovers,_) <- tryReporters ctxt less_serious_reporters $
    
    737
    +                          (vis_items1 ++ invis_items1, suppress_rest)
    
    743 738
            ; mapBagM_ (reportImplic ctxt_for_rest) other_implics
    
    744 739
     
    
    745 740
            -- Check that we have covered all the constraints
    
    ... ... @@ -749,7 +744,7 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics
    749 744
                $$ ppr leftovers)
    
    750 745
            }
    
    751 746
      where
    
    752
    -    env       = cec_tidy ctxt
    
    747
    +    env = cec_tidy ctxt
    
    753 748
     
    
    754 749
         partition_errors :: [DelayedError] -> ([Hole], [Hole], [NotConcreteError], [(TcCoercion, CtLoc)])
    
    755 750
         partition_errors []
    
    ... ... @@ -1439,35 +1434,37 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
    1439 1434
            ; return $ evDelayedError ty err_str }
    
    1440 1435
     
    
    1441 1436
     tryReporters :: SolverReportErrCtxt
    
    1442
    -             -> Bool              -- Suppress errors if this is True
    
    1443
    -                                  -- (over-riding cec_error_reported)
    
    1444 1437
                  -> [ReporterSpec]
    
    1445
    -             -> [ErrorItem]
    
    1446
    -             -> TcM [ErrorItem]
    
    1438
    +             -> ([ErrorItem], Bool)       -- Bool=True <=> an earlier error has been reported,
    
    1439
    +                                          --               so suppress further ones
    
    1440
    +             -> TcM ([ErrorItem], Bool)   -- Returned Bool augments incoming one
    
    1447 1441
     -- Use the first reporter in the list whose predicate says True
    
    1448
    -tryReporters ctxt suppress reporters items
    
    1442
    +tryReporters ctxt reporters items
    
    1449 1443
       = do { traceTc "tryReporters {" (ppr items)
    
    1450 1444
            ; items' <- go reporters items
    
    1451 1445
            ; traceTc "tryReporters }" (ppr items')
    
    1452 1446
            ; return items' }
    
    1453 1447
       where
    
    1454 1448
         -- Use `suppress` to set the `cec_error_reported` flag for these items
    
    1455
    -    ctxt_w_suppress = ctxt { cec_error_reported = suppress }
    
    1449
    +    go :: [ReporterSpec] -> ([ErrorItem], Bool) -> TcM ([ErrorItem], Bool)
    
    1456 1450
         go []     items = return items
    
    1457
    -    go (r:rs) items = do { items' <- tryReporter ctxt_w_suppress r items
    
    1451
    +    go (r:rs) items = do { items' <- tryReporter ctxt r items
    
    1458 1452
                              ; go rs items' }
    
    1459 1453
                           -- Carry on with the rest, because we must make
    
    1460 1454
                           -- deferred bindings for them if we have -fdefer-type-errors
    
    1461 1455
     
    
    1462
    -tryReporter :: SolverReportErrCtxt -> ReporterSpec -> [ErrorItem] -> TcM [ErrorItem]
    
    1463
    -tryReporter ctxt (str, keep_me, reporter) items = case nonEmpty yeses of
    
    1464
    -    Nothing -> return items
    
    1465
    -    Just yeses -> do
    
    1466
    -       { traceTc "tryReporter{ " (text str <+> ppr yeses)
    
    1467
    -       ; reporter ctxt yeses
    
    1468
    -       ; traceTc "tryReporter end }" empty
    
    1469
    -       ; return nos }
    
    1456
    +tryReporter :: SolverReportErrCtxt -> ReporterSpec
    
    1457
    +            -> ([ErrorItem], Bool) -> TcM ([ErrorItem], Bool)
    
    1458
    +tryReporter ctxt (str, keep_me, reporter) (items, suppress)
    
    1459
    +  = case nonEmpty yeses of
    
    1460
    +      Nothing    -> return (items, suppress)
    
    1461
    +      Just yeses -> do
    
    1462
    +         { traceTc "tryReporter{ " (text str <+> ppr yeses)
    
    1463
    +         ; (_, errs_found) <- askErrsFound (reporter ctxt_w_supp yeses)
    
    1464
    +         ; traceTc "tryReporter end }" empty
    
    1465
    +         ; return (nos, suppress || errs_found) }
    
    1470 1466
       where
    
    1467
    +    ctxt_w_supp  = ctxt { cec_error_reported = suppress }
    
    1471 1468
         (yeses, nos) = partition keep items
    
    1472 1469
         keep item = keep_me item (classifyPredType (errorItemPred item))
    
    1473 1470
     
    

  • compiler/GHC/Tc/Solver/Default.hs
    ... ... @@ -993,10 +993,9 @@ last example above.
    993 993
     
    
    994 994
     tryTypeClassDefaulting :: WantedConstraints -> TcS WantedConstraints
    
    995 995
     tryTypeClassDefaulting wc
    
    996
    -  | isEmptyWC wc
    
    997
    -    -- || insolubleWC wc -- See Note [Defaulting insolubles]
    
    996
    +  | isSolvedWC wc -- Not isEmptyWC, see (SCS5) in Note [Shortcut solving]
    
    998 997
       = return wc
    
    999
    -  | otherwise  -- See Note [When to do type-class defaulting]
    
    998
    +  | otherwise     -- See Note [When to do type-class defaulting]
    
    1000 999
       = do { something_happened <- applyDefaultingRules wc
    
    1001 1000
                                    -- See Note [Top-level Defaulting Plan]
    
    1002 1001
            ; solveAgainIf something_happened wc }
    
    ... ... @@ -1007,9 +1006,6 @@ applyDefaultingRules :: WantedConstraints -> TcS Bool
    1007 1006
     -- See Note [How type-class constraints are defaulted]
    
    1008 1007
     
    
    1009 1008
     applyDefaultingRules wanteds
    
    1010
    -  | isSolvedWC wanteds -- not isEmptyWC, see (SCS5) in Note [Shortcut solving]
    
    1011
    -  = return False
    
    1012
    -  | otherwise
    
    1013 1009
       = do { (default_env, extended_rules) <- getDefaultInfo
    
    1014 1010
            ; wanteds                       <- TcS.zonkWC wanteds
    
    1015 1011
     
    
    ... ... @@ -1029,13 +1025,23 @@ applyDefaultingRules wanteds
    1029 1025
                  ; return (wanteds, defaultedGroups)
    
    1030 1026
                  }
    
    1031 1027
     
    
    1032
    -       ; let groups = findDefaultableGroups (default_tys, extended_rules) wanteds
    
    1028
    +      -- Extract from the WantedConstraints
    
    1029
    +      -- a bag of constraints we might default
    
    1030
    +      ; let possibly_defaultable_cts = approximateWC True wanteds
    
    1031
    +              -- True: for the purpose of defaulting we don't care
    
    1032
    +              --       about shape or enclosing equalities
    
    1033
    +              -- See (W3) in Note [ApproximateWC] in GHC.Tc.Types.Constraint
    
    1034
    +
    
    1035
    +       -- Divide then into groups, by the tyvar they constrain
    
    1036
    +       ; let groups = findDefaultableGroups (default_tys, extended_rules)
    
    1037
    +                                            possibly_defaultable_cts
    
    1033 1038
     
    
    1034 1039
            ; traceTcS "applyDefaultingRules {" $
    
    1035 1040
                       vcat [ text "wanteds =" <+> ppr wanteds
    
    1036 1041
                            , text "groups  =" <+> ppr groups
    
    1037 1042
                            , text "info    =" <+> ppr (default_tys, extended_rules) ]
    
    1038 1043
     
    
    1044
    +       -- Try defaulting each group separately
    
    1039 1045
            ; something_happeneds <- mapM (disambigGroup wanteds default_tys) groups
    
    1040 1046
     
    
    1041 1047
            ; traceTcS "applyDefaultingRules }" (ppr something_happeneds)
    
    ... ... @@ -1064,10 +1070,10 @@ applyDefaultingRules wanteds
    1064 1070
     
    
    1065 1071
     findDefaultableGroups
    
    1066 1072
         :: ( [ClassDefaults]
    
    1067
    -       , Bool )            -- extended default rules
    
    1068
    -    -> WantedConstraints   -- Unsolved
    
    1073
    +       , Bool )            -- Extended default rules
    
    1074
    +    -> Bag Ct              -- Unsolved, perhpas defaultable
    
    1069 1075
         -> [(TyVar, [Ct])]
    
    1070
    -findDefaultableGroups (default_tys, extended_defaults) wanteds
    
    1076
    +findDefaultableGroups (default_tys, extended_defaults) simples
    
    1071 1077
       | null default_tys
    
    1072 1078
       = []
    
    1073 1079
       | otherwise
    
    ... ... @@ -1077,11 +1083,6 @@ findDefaultableGroups (default_tys, extended_defaults) wanteds
    1077 1083
         , defaultable_tyvar tv
    
    1078 1084
         , defaultable_classes (map sndOf3 group) ]
    
    1079 1085
       where
    
    1080
    -    simples  = approximateWC True wanteds
    
    1081
    -      -- True: for the purpose of defaulting we don't care
    
    1082
    -      --       about shape or enclosing equalities
    
    1083
    -      -- See (W3) in Note [ApproximateWC] in GHC.Tc.Types.Constraint
    
    1084
    -
    
    1085 1086
         (unaries, non_unaries) = partitionWith find_unary (bagToList simples)
    
    1086 1087
         unary_groups           = equivClasses cmp_tv unaries
    
    1087 1088
     
    

  • compiler/GHC/Tc/Types/Constraint.hs
    ... ... @@ -1824,6 +1824,10 @@ type ApproxWC = ( Bag Ct -- Free quantifiable constraints
    1824 1824
        -- See (DP1) in Note [decideAndPromoteTyVars] in GHC.Tc.Solver
    
    1825 1825
     approximateWC :: Bool -> WantedConstraints -> Bag Ct
    
    1826 1826
     approximateWC include_non_quantifiable cts
    
    1827
    +  | any insolubleWantedCt (wc_simple cts)
    
    1828
    +  = -- See (W5) in Note [ApproximateWC]
    
    1829
    +    emptyCts
    
    1830
    +  | otherwise
    
    1827 1831
       = fst (approximateWCX include_non_quantifiable cts)
    
    1828 1832
     
    
    1829 1833
     approximateWCX :: Bool -> WantedConstraints -> ApproxWC
    
    ... ... @@ -1861,7 +1865,7 @@ approximateWCX include_non_quantifiable wc
    1861 1865
                -- There can be (insoluble) Given constraints in wc_simple,
    
    1862 1866
                -- there so that we get error reports for unreachable code
    
    1863 1867
                -- See `given_insols` in GHC.Tc.Solver.Solve.solveImplication
    
    1864
    -       | insolubleCt ct                       = acc
    
    1868
    +       | insolubleCt ct                       = acc  -- See (W5)
    
    1865 1869
            | pred_tvs `intersectsVarSet` skol_tvs = acc
    
    1866 1870
            | include_non_quantifiable             = add_to_quant
    
    1867 1871
            | is_quantifiable encl_eqs (ctPred ct) = add_to_quant
    
    ... ... @@ -1973,6 +1977,18 @@ Wrinkle (W4)
    1973 1977
       SPECIALISE pragmas: see (WFA4) in Note [Solving a Wanted forall-constraint].
    
    1974 1978
       But there we don't use approximateWC.)
    
    1975 1979
     
    
    1980
    +Wrinkle (W5)
    
    1981
    +  If an implication is insoluble we give up and return no constraints. We
    
    1982
    +  do this locally, per-implication, so that sister soluble implications are
    
    1983
    +  defulted normally.
    
    1984
    +
    
    1985
    +  * For inferring types in `simplifyInfer` dhere is no point in inferring a
    
    1986
    +    type with carefully chosen constraints if there is a type error anyway
    
    1987
    +
    
    1988
    +  * For defaulting see Note [When to do type-class defaulting].  A tiresome
    
    1989
    +    complication is that in the top-level WantedConstraints we have no
    
    1990
    +    `ic_status` flag to look at, so we consult the `wc_simple` directly.
    
    1991
    +
    
    1976 1992
     ------ Historical note -----------
    
    1977 1993
     There used to be a second caveat, driven by #8155
    
    1978 1994
     
    

  • testsuite/tests/overloadedstrings/should_fail/T25926.stderr
    1
    +T25926.hs:3:6: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    2
    +    • No instance for ‘Eq a’ arising from the literal ‘0’
    
    3
    +      Possible fix:
    
    4
    +        add (Eq a) to the context of
    
    5
    +          the inferred type of f :: () -> a -> ()
    
    6
    +    • In the pattern: 0
    
    7
    +      In an equation for ‘f’: f () 0 = ()
    
    8
    +
    
    1 9
     T25926.hs:4:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    2 10
         • Couldn't match expected type ‘()’ with actual type ‘Char’
    
    3 11
         • In the pattern: 'a'
    

  • testsuite/tests/overloadedstrings/should_fail/T27124.stderr
    ... ... @@ -4,3 +4,17 @@ T27124.hs:6:5: warning: [GHC-18872] [-Wdeferred-type-errors (in -Wdefault)]
    4 4
         • In the pattern: "HI"
    
    5 5
           In an equation for ‘foo’: foo "HI" = True
    
    6 6
     
    
    7
    +T27124.hs:9:8: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    8
    +    • Ambiguous type variable ‘f0’ arising from a use of ‘pure’
    
    9
    +      prevents the constraint ‘(Applicative f0)’ from being solved.
    
    10
    +      Relevant bindings include main :: f0 () (bound at T27124.hs:9:1)
    
    11
    +      Probable fix: use a type annotation to specify what ‘f0’ should be.
    
    12
    +      Potentially matching instances:
    
    13
    +        instance Applicative IO -- Defined in ‘GHC.Internal.Base’
    
    14
    +        instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’
    
    15
    +        ...plus six others
    
    16
    +        ...plus one instance involving out-of-scope types
    
    17
    +        (use -fprint-potential-instances to see them all)
    
    18
    +    • In the expression: pure ()
    
    19
    +      In an equation for ‘main’: main = pure ()
    
    20
    +

  • testsuite/tests/patsyn/should_fail/records-nofieldselectors.stderr
    1
    -
    
    2 1
     records-nofieldselectors.hs:9:12: error: [GHC-88464]
    
    3
    -    Variable not in scope: x :: [a0] -> Int
    
    2
    +    Variable not in scope: x :: [Integer] -> Int
    
    4 3
         Suggested fix:
    
    5 4
           Notice that ‘x’ is a field selector
    
    6 5
           that has been suppressed by NoFieldSelectors.
    
    6
    +

  • testsuite/tests/typecheck/should_compile/T11254.stderr
    1
    -
    
    2 1
     T11254.hs:16:10: warning: [GHC-18872] [-Wdeferred-type-errors (in -Wdefault)]
    
    3 2
         • Couldn't match type ‘Frac Int’ with ‘Int’
    
    4 3
             arising from the superclasses of an instance declaration
    
    5 4
         • In the instance declaration for ‘ID Rational’
    
    6 5
     
    
    6
    +T11254.hs:16:10: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    7
    +    • No instance for ‘Fractional Int’
    
    8
    +        arising from the superclasses of an instance declaration
    
    9
    +    • In the instance declaration for ‘ID Rational’
    
    10
    +
    
    11
    +T11254.hs:16:10: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    12
    +    • No instance for ‘ID Int’
    
    13
    +        arising from the superclasses of an instance declaration
    
    14
    +    • In the instance declaration for ‘ID Rational’
    
    15
    +
    
    7 16
     T11254.hs:18:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    8 17
         • Couldn't match type ‘GHC.Internal.Real.Ratio Integer’ with ‘Int’
    
    9 18
           Expected: Rational -> Frac Rational
    
    ... ... @@ -13,3 +22,4 @@ T11254.hs:18:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    13 22
             Instance sig: Rational -> Rational
    
    14 23
                Class sig: Rational -> Frac Rational
    
    15 24
           In the instance declaration for ‘ID Rational’
    
    25
    +

  • testsuite/tests/typecheck/should_compile/T15370.stderr
    1
    -
    
    2 1
     T15370.hs:14:10: warning: [GHC-25897] [-Wdeferred-type-errors (in -Wdefault)]
    
    3 2
         • Couldn't match type ‘n’ with ‘j’
    
    4 3
           Expected: n :~: j
    
    ... ... @@ -27,6 +26,17 @@ T15370.hs:20:13: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    27 26
             no :: S r (bound at T15370.hs:18:7)
    
    28 27
             right :: S r -> () (bound at T15370.hs:18:1)
    
    29 28
     
    
    29
    +T15370.hs:20:16: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    30
    +    • Could not deduce ‘Num ()’ arising from a use of ‘+’
    
    31
    +      from the context: y ~ x
    
    32
    +        bound by a pattern with constructor:
    
    33
    +                   Refl :: forall {k} (a :: k). a :~: a,
    
    34
    +                 in a case alternative
    
    35
    +        at T15370.hs:20:5-8
    
    36
    +    • In the expression: no + _
    
    37
    +      In a case alternative: Refl -> no + _
    
    38
    +      In the expression: case mkRefl @x @y of Refl -> no + _
    
    39
    +
    
    30 40
     T15370.hs:20:18: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    
    31 41
         • Found hole: _ :: ()
    
    32 42
         • In the second argument of ‘(+)’, namely ‘_’
    
    ... ... @@ -41,3 +51,4 @@ T15370.hs:20:18: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    41 51
             mempty :: forall a. Monoid a => a
    
    42 52
             maxBound :: forall a. Bounded a => a
    
    43 53
             minBound :: forall a. Bounded a => a
    
    54
    +

  • testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
    ... ... @@ -67,8 +67,7 @@ valid_hole_fits.hs:24:9: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    67 67
                (and originally defined at ValidHoleFits.hs:4:12-22))
    
    68 68
     
    
    69 69
     valid_hole_fits.hs:27:5: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    
    70
    -    • Found hole: _ :: t0 -> Maybe Integer
    
    71
    -      Where: ‘t0’ is an ambiguous type variable
    
    70
    +    • Found hole: _ :: Integer -> Maybe Integer
    
    72 71
         • In the expression: _ 2
    
    73 72
           In an equation for ‘k’: k = _ 2
    
    74 73
         • Relevant bindings include
    
    ... ... @@ -87,6 +86,20 @@ valid_hole_fits.hs:27:5: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    87 86
               (imported from ‘Prelude’ at valid_hole_fits.hs:3:1-40
    
    88 87
                (and originally defined in ‘GHC.Internal.Base’))
    
    89 88
     
    
    89
    +valid_hole_fits.hs:30:5: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    90
    +    • Ambiguous type variable ‘a1’ arising from a use of ‘show’
    
    91
    +      prevents the constraint ‘(Show a1)’ from being solved.
    
    92
    +      Probable fix: use a type annotation to specify what ‘a1’ should be.
    
    93
    +      Potentially matching instances:
    
    94
    +        instance (Show a, Show b) => Show (Either a b)
    
    95
    +          -- Defined in ‘GHC.Internal.Data.Either’
    
    96
    +        instance Show Integer -- Defined in ‘GHC.Internal.Show’
    
    97
    +        ...plus 26 others
    
    98
    +        ...plus 40 instances involving out-of-scope types
    
    99
    +        (use -fprint-potential-instances to see them all)
    
    100
    +    • In the expression: show _
    
    101
    +      In an equation for ‘f’: f = show _
    
    102
    +
    
    90 103
     valid_hole_fits.hs:30:10: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    
    91 104
         • Found hole: _ :: a1
    
    92 105
           Where: ‘a1’ is an ambiguous type variable
    
    ... ... @@ -123,6 +136,20 @@ valid_hole_fits.hs:30:10: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    123 136
               (imported from ‘Prelude’ at valid_hole_fits.hs:3:1-40
    
    124 137
                (and originally defined in ‘GHC.Internal.Float’))
    
    125 138
     
    
    139
    +valid_hole_fits.hs:34:5: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    140
    +    • Ambiguous type variable ‘a0’ arising from a use of ‘show’
    
    141
    +      prevents the constraint ‘(Show a0)’ from being solved.
    
    142
    +      Probable fix: use a type annotation to specify what ‘a0’ should be.
    
    143
    +      Potentially matching instances:
    
    144
    +        instance (Show a, Show b) => Show (Either a b)
    
    145
    +          -- Defined in ‘GHC.Internal.Data.Either’
    
    146
    +        instance Show Integer -- Defined in ‘GHC.Internal.Show’
    
    147
    +        ...plus 26 others
    
    148
    +        ...plus 35 instances involving out-of-scope types
    
    149
    +        (use -fprint-potential-instances to see them all)
    
    150
    +    • In the expression: show (_ (_ :: Bool))
    
    151
    +      In an equation for ‘h’: h = show (_ (_ :: Bool))
    
    152
    +
    
    126 153
     valid_hole_fits.hs:34:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
    
    127 154
         • Found hole: _ :: Bool -> a0
    
    128 155
           Where: ‘a0’ is an ambiguous type variable
    

  • testsuite/tests/typecheck/should_fail/ClassOperator.stderr
    ... ... @@ -2,51 +2,51 @@ ClassOperator.hs:14:3: error: [GHC-39999]
    2 2
         • Could not deduce ‘a ><> b0’
    
    3 3
           from the context: a ><> b
    
    4 4
             bound by the type signature for:
    
    5
    -                   (<**) :: forall a b. (a ><> b) => a -> a -> ()
    
    5
    +                   (**>) :: forall a b. (a ><> b) => a -> a -> ()
    
    6 6
             at ClassOperator.hs:14:3-44
    
    7 7
           The type variable ‘b0’ is ambiguous
    
    8
    -    • In the ambiguity check for ‘<**’
    
    8
    +    • In the ambiguity check for ‘**>’
    
    9 9
           To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    
    10 10
           When checking the class method:
    
    11
    -        (<**) :: forall a b. (a ><> b) => a -> a -> ()
    
    11
    +        (**>) :: forall a b. (a ><> b) => a -> a -> ()
    
    12 12
           In the class declaration for ‘><>’
    
    13 13
     
    
    14 14
     ClassOperator.hs:14:3: error: [GHC-39999]
    
    15 15
         • Could not deduce ‘a ><> b0’
    
    16 16
           from the context: a ><> b
    
    17 17
             bound by the type signature for:
    
    18
    -                   (>**) :: forall a b. (a ><> b) => a -> a -> ()
    
    18
    +                   (**<) :: forall a b. (a ><> b) => a -> a -> ()
    
    19 19
             at ClassOperator.hs:14:3-44
    
    20 20
           The type variable ‘b0’ is ambiguous
    
    21
    -    • In the ambiguity check for ‘>**’
    
    21
    +    • In the ambiguity check for ‘**<’
    
    22 22
           To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    
    23 23
           When checking the class method:
    
    24
    -        (>**) :: forall a b. (a ><> b) => a -> a -> ()
    
    24
    +        (**<) :: forall a b. (a ><> b) => a -> a -> ()
    
    25 25
           In the class declaration for ‘><>’
    
    26 26
     
    
    27 27
     ClassOperator.hs:14:3: error: [GHC-39999]
    
    28 28
         • Could not deduce ‘a ><> b0’
    
    29 29
           from the context: a ><> b
    
    30 30
             bound by the type signature for:
    
    31
    -                   (**<) :: forall a b. (a ><> b) => a -> a -> ()
    
    31
    +                   (>**) :: forall a b. (a ><> b) => a -> a -> ()
    
    32 32
             at ClassOperator.hs:14:3-44
    
    33 33
           The type variable ‘b0’ is ambiguous
    
    34
    -    • In the ambiguity check for ‘**<’
    
    34
    +    • In the ambiguity check for ‘>**’
    
    35 35
           To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    
    36 36
           When checking the class method:
    
    37
    -        (**<) :: forall a b. (a ><> b) => a -> a -> ()
    
    37
    +        (>**) :: forall a b. (a ><> b) => a -> a -> ()
    
    38 38
           In the class declaration for ‘><>’
    
    39 39
     
    
    40 40
     ClassOperator.hs:14:3: error: [GHC-39999]
    
    41 41
         • Could not deduce ‘a ><> b0’
    
    42 42
           from the context: a ><> b
    
    43 43
             bound by the type signature for:
    
    44
    -                   (**>) :: forall a b. (a ><> b) => a -> a -> ()
    
    44
    +                   (<**) :: forall a b. (a ><> b) => a -> a -> ()
    
    45 45
             at ClassOperator.hs:14:3-44
    
    46 46
           The type variable ‘b0’ is ambiguous
    
    47
    -    • In the ambiguity check for ‘**>’
    
    47
    +    • In the ambiguity check for ‘<**’
    
    48 48
           To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    
    49 49
           When checking the class method:
    
    50
    -        (**>) :: forall a b. (a ><> b) => a -> a -> ()
    
    50
    +        (<**) :: forall a b. (a ><> b) => a -> a -> ()
    
    51 51
           In the class declaration for ‘><>’
    
    52 52
     

  • testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
    ... ... @@ -59,6 +59,20 @@ DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
    59 59
           In the expression: getVal 3 4
    
    60 60
           In a stmt of a 'do' block: Just x <- getVal 3 4
    
    61 61
     
    
    62
    +DoExpansion2.hs:34:31: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    63
    +    • Ambiguous type variable ‘t0’ arising from the literal ‘4’
    
    64
    +      prevents the constraint ‘(Num t0)’ from being solved.
    
    65
    +      Probable fix: use a type annotation to specify what ‘t0’ should be.
    
    66
    +      Potentially matching instances:
    
    67
    +        instance Num Integer -- Defined in ‘GHC.Internal.Num’
    
    68
    +        instance Num Double -- Defined in ‘GHC.Internal.Float’
    
    69
    +        ...plus three others
    
    70
    +        ...plus one instance involving out-of-scope types
    
    71
    +        (use -fprint-potential-instances to see them all)
    
    72
    +    • In the second argument of ‘getVal’, namely ‘4’
    
    73
    +      In the expression: getVal 3 4
    
    74
    +      In a stmt of a 'do' block: Just x <- getVal 3 4
    
    75
    +
    
    62 76
     DoExpansion2.hs:39:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    63 77
         • Couldn't match type ‘[Char]’ with ‘Int’
    
    64 78
           Expected: Int
    

  • testsuite/tests/typecheck/should_fail/DoExpansion3.stderr
    1
    +DoExpansion3.hs:12:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    2
    +    • No instance for ‘Num String’ arising from the literal ‘1’
    
    3
    +    • In the expression: 1
    
    4
    +      In an equation for ‘x’: x = 1
    
    5
    +      In a stmt of a 'do' block: let x = 1
    
    6
    +
    
    7
    +DoExpansion3.hs:13:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    8
    +    • Ambiguous type variable ‘a1’ arising from the literal ‘2’
    
    9
    +      prevents the constraint ‘(Num a1)’ from being solved.
    
    10
    +      Relevant bindings include y :: a1 (bound at DoExpansion3.hs:13:16)
    
    11
    +      Probable fix: use a type annotation to specify what ‘a1’ should be.
    
    12
    +      Potentially matching instances:
    
    13
    +        instance Num Integer -- Defined in ‘GHC.Internal.Num’
    
    14
    +        instance Num Double -- Defined in ‘GHC.Internal.Float’
    
    15
    +        ...plus three others
    
    16
    +        ...plus one instance involving out-of-scope types
    
    17
    +        (use -fprint-potential-instances to see them all)
    
    18
    +    • In the expression: 2
    
    19
    +      In an equation for ‘y’: y = 2
    
    20
    +      In a stmt of a 'do' block: let y = 2
    
    21
    +
    
    1 22
     DoExpansion3.hs:15:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    2 23
         • Couldn't match type ‘[Char]’ with ‘Int’
    
    3 24
           Expected: Int
    
    ... ... @@ -15,6 +36,38 @@ DoExpansion3.hs:18:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
    15 36
           In an equation for ‘y’: y = getChar 2
    
    16 37
         • Relevant bindings include y :: t (bound at DoExpansion3.hs:18:16)
    
    17 38
     
    
    39
    +DoExpansion3.hs:18:28: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    40
    +    • Ambiguous type variable ‘t0’ arising from the literal ‘2’
    
    41
    +      prevents the constraint ‘(Num t0)’ from being solved.
    
    42
    +      Probable fix: use a type annotation to specify what ‘t0’ should be.
    
    43
    +      Potentially matching instances:
    
    44
    +        instance Num Integer -- Defined in ‘GHC.Internal.Num’
    
    45
    +        instance Num Double -- Defined in ‘GHC.Internal.Float’
    
    46
    +        ...plus three others
    
    47
    +        ...plus one instance involving out-of-scope types
    
    48
    +        (use -fprint-potential-instances to see them all)
    
    49
    +    • In the first argument of ‘getChar’, namely ‘2’
    
    50
    +      In the expression: getChar 2
    
    51
    +      In an equation for ‘y’: y = getChar 2
    
    52
    +
    
    53
    +DoExpansion3.hs:19:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    54
    +    • Ambiguous type variable ‘a0’ arising from the literal ‘3’
    
    55
    +      prevents the constraint ‘(Num a0)’ from being solved.
    
    56
    +      Relevant bindings include z :: a0 (bound at DoExpansion3.hs:19:16)
    
    57
    +      Probable fix: use a type annotation to specify what ‘a0’ should be.
    
    58
    +      Potentially matching instances:
    
    59
    +        instance Num Integer -- Defined in ‘GHC.Internal.Num’
    
    60
    +        instance Num Double -- Defined in ‘GHC.Internal.Float’
    
    61
    +        ...plus three others
    
    62
    +        ...plus one instance involving out-of-scope types
    
    63
    +        (use -fprint-potential-instances to see them all)
    
    64
    +    • In the expression: 3
    
    65
    +      In an equation for ‘z’: z = 3
    
    66
    +      In a stmt of a 'do' block:
    
    67
    +        let x = 1
    
    68
    +            y = getChar 2
    
    69
    +            z = 3
    
    70
    +
    
    18 71
     DoExpansion3.hs:25:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    19 72
         • Couldn't match expected type ‘Int’ with actual type ‘Char’
    
    20 73
         • In the first argument of ‘(+)’, namely ‘x’
    
    ... ... @@ -29,6 +82,12 @@ DoExpansion3.hs:27:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
    29 82
             do Just x <- getChar
    
    30 83
                return x
    
    31 84
     
    
    85
    +DoExpansion3.hs:32:11: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    86
    +    • No instance for ‘Num String’ arising from the literal ‘1’
    
    87
    +    • In the expression: 1
    
    88
    +      In an equation for ‘a’: a = 1
    
    89
    +      In a stmt of a 'do' block: let a = 1
    
    90
    +
    
    32 91
     DoExpansion3.hs:33:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
    
    33 92
         • Couldn't match type ‘()’ with ‘Int’
    
    34 93
           Expected: IO Int
    
    ... ... @@ -44,3 +103,12 @@ DoExpansion3.hs:33:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault
    44 103
                      let a = 1
    
    45 104
                      putStrLn $ a + ""
    
    46 105
     
    
    106
    +DoExpansion3.hs:33:16: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
    
    107
    +    • No instance for ‘Num String’ arising from a use of ‘+’
    
    108
    +    • In the second argument of ‘($)’, namely ‘a + ""’
    
    109
    +      In a stmt of a 'do' block: putStrLn $ a + ""
    
    110
    +      In the expression:
    
    111
    +        do let z :: Int = 3
    
    112
    +           let a = 1
    
    113
    +           putStrLn $ a + ""
    
    114
    +

  • testsuite/tests/typecheck/should_fail/T22940.stderr
    1
    -
    
    2 1
     T22940.hs:4:48: error: [GHC-88464]
    
    3
    -    Variable not in scope: a
    2
    +    Variable not in scope: a :: Integer
    
    3
    +

  • testsuite/tests/typecheck/should_fail/T26823.stderr
    1 1
     T26823.hs:12:14: error: [GHC-25897]
    
    2
    -    • Couldn't match expected type ‘a0 -> a0 -> t’ with actual type ‘t’
    
    2
    +    • Couldn't match expected type ‘Integer -> Integer -> t’
    
    3
    +                  with actual type ‘t’
    
    3 4
           ‘t’ is a rigid type variable bound by
    
    4
    -        the inferred type of rem :: a0 -> a0 -> t
    
    5
    +        the inferred type of rem :: Integer -> Integer -> t
    
    5 6
             at T26823.hs:12:5-29
    
    6 7
         • In the expression: off `rem` vecAli
    
    7 8
           In an equation for ‘rem’: !rem = off `rem` vecAli
    
    ... ... @@ -12,21 +13,13 @@ T26823.hs:12:14: error: [GHC-25897]
    12 13
                 !rem = off `rem` vecAli
    
    13 14
                 !start = if rem == 0 then off else off + (vecAli - rem)
    
    14 15
         • Relevant bindings include
    
    15
    -        rem :: a0 -> a0 -> t (bound at T26823.hs:12:6)
    
    16
    -        off :: a0 (bound at T26823.hs:8:6)
    
    17
    -        vecAli :: a0 (bound at T26823.hs:10:6)
    
    18
    -        size :: a0 (bound at T26823.hs:9:6)
    
    16
    +        rem :: Integer -> Integer -> t (bound at T26823.hs:12:6)
    
    19 17
     
    
    20
    -T26823.hs:13:57: error: [GHC-27958]
    
    21
    -    • Couldn't match expected type ‘a0’
    
    22
    -                  with actual type ‘a0 -> a0 -> t0’
    
    23
    -    • In the second argument of ‘(-)’, namely ‘rem’
    
    18
    +T26823.hs:13:57: error: [GHC-83865]
    
    19
    +    • Couldn't match expected type ‘Integer’
    
    20
    +                  with actual type ‘Integer -> Integer -> t0’
    
    21
    +    • Probable cause: ‘rem’ is applied to too few arguments
    
    22
    +      In the second argument of ‘(-)’, namely ‘rem’
    
    24 23
           In the second argument of ‘(+)’, namely ‘(vecAli - rem)’
    
    25 24
           In the expression: off + (vecAli - rem)
    
    26
    -    • Relevant bindings include
    
    27
    -        start :: a0 (bound at T26823.hs:13:6)
    
    28
    -        rem :: forall {t}. a0 -> a0 -> t (bound at T26823.hs:12:6)
    
    29
    -        off :: a0 (bound at T26823.hs:8:6)
    
    30
    -        vecAli :: a0 (bound at T26823.hs:10:6)
    
    31
    -        size :: a0 (bound at T26823.hs:9:6)
    
    32 25
     

  • testsuite/tests/typecheck/should_fail/T5691.stderr
    1
    -
    
    2 1
     T5691.hs:24:10: error: [GHC-39999]
    
    3
    -    • No instance for ‘Alternative RecDecParser’
    
    2
    +    • No instance for ‘Monad RecDecParser’
    
    4 3
             arising from the superclasses of an instance declaration
    
    5 4
         • In the instance declaration for ‘MonadPlus RecDecParser’
    
    6 5
     
    
    7 6
     T5691.hs:24:10: error: [GHC-39999]
    
    8
    -    • No instance for ‘Monad RecDecParser’
    
    7
    +    • No instance for ‘Alternative RecDecParser’
    
    9 8
             arising from the superclasses of an instance declaration
    
    10 9
         • In the instance declaration for ‘MonadPlus RecDecParser’
    
    10
    +

  • testsuite/tests/typecheck/should_fail/T7437.stderr
    1
    -
    
    2
    -T7437.hs:14:13: error: [GHC-72771]
    
    3
    -    • The default type signature for put:
    
    4
    -        forall t. (Generic t, GPut (Rep t)) => t -> [()]
    
    5
    -      does not match its corresponding non-default type signature
    
    6
    -    • When checking the class method:
    
    7
    -        put :: forall a. Put a => a -> [()]
    
    8
    -      In the class declaration for ‘Put’
    
    9
    -
    
    10 1
     T7437.hs:14:13: error: [GHC-39999]
    
    11 2
         • Could not deduce ‘Put a0’
    
    12 3
           from the context: (Put a, Generic t, GPut (Rep t))
    
    ... ... @@ -18,3 +9,12 @@ T7437.hs:14:13: error: [GHC-39999]
    18 9
           To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    
    19 10
           When checking the class method: put :: forall a. Put a => a -> [()]
    
    20 11
           In the class declaration for ‘Put’
    
    12
    +
    
    13
    +T7437.hs:14:13: error: [GHC-72771]
    
    14
    +    • The default type signature for put:
    
    15
    +        forall t. (Generic t, GPut (Rep t)) => t -> [()]
    
    16
    +      does not match its corresponding non-default type signature
    
    17
    +    • When checking the class method:
    
    18
    +        put :: forall a. Put a => a -> [()]
    
    19
    +      In the class declaration for ‘Put’
    
    20
    +

  • testsuite/tests/typecheck/should_fail/tcfail019.stderr
    1
    -
    
    2 1
     tcfail019.hs:18:10: error: [GHC-39999]
    
    3
    -    • No instance for ‘B [a]’
    
    2
    +    • No instance for ‘C [a]’
    
    4 3
             arising from the superclasses of an instance declaration
    
    5 4
         • In the instance declaration for ‘D [a]’
    
    6 5
     
    
    7 6
     tcfail019.hs:18:10: error: [GHC-39999]
    
    8
    -    • No instance for ‘C [a]’
    
    7
    +    • No instance for ‘B [a]’
    
    9 8
             arising from the superclasses of an instance declaration
    
    10 9
         • In the instance declaration for ‘D [a]’
    
    10
    +