[Git][ghc/ghc][wip/T27731] 2 commits: Wibble comment
Simon Peyton Jones pushed to branch wip/T27731 at Glasgow Haskell Compiler / GHC Commits: 7020442a by Simon Peyton Jones at 2026-09-29T09:09:41+01:00 Wibble comment - - - - - 2c3c41a4 by Simon Peyton Jones at 2026-09-29T11:00:21+01:00 Improvements - - - - - 18 changed files: - compiler/GHC/Builtin/WiredIn/Ids.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Solver/Default.hs - compiler/GHC/Tc/Types/Constraint.hs - testsuite/tests/overloadedstrings/should_fail/T25926.stderr - testsuite/tests/overloadedstrings/should_fail/T27124.stderr - testsuite/tests/patsyn/should_fail/records-nofieldselectors.stderr - testsuite/tests/typecheck/should_compile/T11254.stderr - testsuite/tests/typecheck/should_compile/T15370.stderr - testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr - testsuite/tests/typecheck/should_fail/ClassOperator.stderr - testsuite/tests/typecheck/should_fail/DoExpansion2.stderr - testsuite/tests/typecheck/should_fail/DoExpansion3.stderr - testsuite/tests/typecheck/should_fail/T22940.stderr - testsuite/tests/typecheck/should_fail/T26823.stderr - testsuite/tests/typecheck/should_fail/T5691.stderr - testsuite/tests/typecheck/should_fail/T7437.stderr - testsuite/tests/typecheck/should_fail/tcfail019.stderr Changes: ===================================== compiler/GHC/Builtin/WiredIn/Ids.hs ===================================== @@ -600,8 +600,8 @@ Wrinkles (W1) Sometimes case (2) above needs to apply `noinline` to a type of kind Constraint; e.g. noinline @(Eq Int) $dfEqInt - We don't have type-or-kind polymorphism, so we simply have two `inline` - Ids, namely `noinlineId` and `noinlineConstraintId`. + We don't have type-or-constraint polymorphism, so we simply have two + `inline` Ids, namely `noinlineId` and `noinlineConstraintId`. (W2) Note that noinline as currently implemented can hide some simplifications 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 (vis_items, invis_items) = partition (isVisibleOrigin . errorItemOrigin) tidy_items - ; (vis_items1, vis_serious_errs) - <- askErrsFound $ - tryReporters ctxt suppress_insols serious_reporters vis_items - - ; let suppress_invis = suppress_insols || vis_serious_errs - ; (invis_items1, invis_serious_errs) - <- askErrsFound $ - tryReporters ctxt suppress_invis serious_reporters invis_items + ; (vis_items1, suppress_invis) <- tryReporters ctxt serious_reporters + (vis_items, suppress_insols) + ; (invis_items1, suppress_others) <- tryReporters ctxt serious_reporters + (invis_items, suppress_invis) -- Now take account of the inherited cec_error_reported, and augment it -- to suppress further errors if we have found any serious errors locally -- See (SLIE2) in Note Note [cec_error_reported: suppressing less-serious errors] ; let suppress_implics = cec_error_reported ctxt - || suppress_invis - || invis_serious_errs + || suppress_others ctxt_for_implics = ctxt { cec_error_reported = suppress_implics } (insol_implics, other_implics) = partitionBag insolubleImplic implics -- Next, deal with the insoluble implications - ; (_, implic_errs) - <- askErrsFound $ mapBagM_ (reportImplic ctxt_for_implics) insol_implics + ; (_, implic_errs) <- askErrsFound $ + mapBagM_ (reportImplic ctxt_for_implics) insol_implics -- Finally, deal with the less-serious constraints, -- both local and implications -- suppressing if any errors have been reported so far ; let suppress_rest = suppress_implics || implic_errs ctxt_for_rest = ctxt { cec_error_reported = suppress_rest } - ; leftovers <- tryReporters ctxt suppress_rest less_serious_reporters $ - (vis_items1 ++ invis_items1) + ; (leftovers,_) <- tryReporters ctxt less_serious_reporters $ + (vis_items1 ++ invis_items1, suppress_rest) ; mapBagM_ (reportImplic ctxt_for_rest) other_implics -- Check that we have covered all the constraints @@ -749,7 +744,7 @@ reportWanteds ctxt tc_lvl wc@(WC { wc_simple = simples, wc_impl = implics $$ ppr leftovers) } where - env = cec_tidy ctxt + env = cec_tidy ctxt partition_errors :: [DelayedError] -> ([Hole], [Hole], [NotConcreteError], [(TcCoercion, CtLoc)]) partition_errors [] @@ -1439,35 +1434,37 @@ mkErrorTerm ct_loc ty ctxt msg supp hints ; return $ evDelayedError ty err_str } tryReporters :: SolverReportErrCtxt - -> Bool -- Suppress errors if this is True - -- (over-riding cec_error_reported) -> [ReporterSpec] - -> [ErrorItem] - -> TcM [ErrorItem] + -> ([ErrorItem], Bool) -- Bool=True <=> an earlier error has been reported, + -- so suppress further ones + -> TcM ([ErrorItem], Bool) -- Returned Bool augments incoming one -- Use the first reporter in the list whose predicate says True -tryReporters ctxt suppress reporters items +tryReporters ctxt reporters items = do { traceTc "tryReporters {" (ppr items) ; items' <- go reporters items ; traceTc "tryReporters }" (ppr items') ; return items' } where -- Use `suppress` to set the `cec_error_reported` flag for these items - ctxt_w_suppress = ctxt { cec_error_reported = suppress } + go :: [ReporterSpec] -> ([ErrorItem], Bool) -> TcM ([ErrorItem], Bool) go [] items = return items - go (r:rs) items = do { items' <- tryReporter ctxt_w_suppress r items + go (r:rs) items = do { items' <- tryReporter ctxt r items ; go rs items' } -- Carry on with the rest, because we must make -- deferred bindings for them if we have -fdefer-type-errors -tryReporter :: SolverReportErrCtxt -> ReporterSpec -> [ErrorItem] -> TcM [ErrorItem] -tryReporter ctxt (str, keep_me, reporter) items = case nonEmpty yeses of - Nothing -> return items - Just yeses -> do - { traceTc "tryReporter{ " (text str <+> ppr yeses) - ; reporter ctxt yeses - ; traceTc "tryReporter end }" empty - ; return nos } +tryReporter :: SolverReportErrCtxt -> ReporterSpec + -> ([ErrorItem], Bool) -> TcM ([ErrorItem], Bool) +tryReporter ctxt (str, keep_me, reporter) (items, suppress) + = case nonEmpty yeses of + Nothing -> return (items, suppress) + Just yeses -> do + { traceTc "tryReporter{ " (text str <+> ppr yeses) + ; (_, errs_found) <- askErrsFound (reporter ctxt_w_supp yeses) + ; traceTc "tryReporter end }" empty + ; return (nos, suppress || errs_found) } where + ctxt_w_supp = ctxt { cec_error_reported = suppress } (yeses, nos) = partition keep items keep item = keep_me item (classifyPredType (errorItemPred item)) ===================================== compiler/GHC/Tc/Solver/Default.hs ===================================== @@ -993,10 +993,9 @@ last example above. tryTypeClassDefaulting :: WantedConstraints -> TcS WantedConstraints tryTypeClassDefaulting wc - | isEmptyWC wc - -- || insolubleWC wc -- See Note [Defaulting insolubles] + | isSolvedWC wc -- Not isEmptyWC, see (SCS5) in Note [Shortcut solving] = return wc - | otherwise -- See Note [When to do type-class defaulting] + | otherwise -- See Note [When to do type-class defaulting] = do { something_happened <- applyDefaultingRules wc -- See Note [Top-level Defaulting Plan] ; solveAgainIf something_happened wc } @@ -1007,9 +1006,6 @@ applyDefaultingRules :: WantedConstraints -> TcS Bool -- See Note [How type-class constraints are defaulted] applyDefaultingRules wanteds - | isSolvedWC wanteds -- not isEmptyWC, see (SCS5) in Note [Shortcut solving] - = return False - | otherwise = do { (default_env, extended_rules) <- getDefaultInfo ; wanteds <- TcS.zonkWC wanteds @@ -1029,13 +1025,23 @@ applyDefaultingRules wanteds ; return (wanteds, defaultedGroups) } - ; let groups = findDefaultableGroups (default_tys, extended_rules) wanteds + -- Extract from the WantedConstraints + -- a bag of constraints we might default + ; let possibly_defaultable_cts = approximateWC True wanteds + -- True: for the purpose of defaulting we don't care + -- about shape or enclosing equalities + -- See (W3) in Note [ApproximateWC] in GHC.Tc.Types.Constraint + + -- Divide then into groups, by the tyvar they constrain + ; let groups = findDefaultableGroups (default_tys, extended_rules) + possibly_defaultable_cts ; traceTcS "applyDefaultingRules {" $ vcat [ text "wanteds =" <+> ppr wanteds , text "groups =" <+> ppr groups , text "info =" <+> ppr (default_tys, extended_rules) ] + -- Try defaulting each group separately ; something_happeneds <- mapM (disambigGroup wanteds default_tys) groups ; traceTcS "applyDefaultingRules }" (ppr something_happeneds) @@ -1064,10 +1070,10 @@ applyDefaultingRules wanteds findDefaultableGroups :: ( [ClassDefaults] - , Bool ) -- extended default rules - -> WantedConstraints -- Unsolved + , Bool ) -- Extended default rules + -> Bag Ct -- Unsolved, perhpas defaultable -> [(TyVar, [Ct])] -findDefaultableGroups (default_tys, extended_defaults) wanteds +findDefaultableGroups (default_tys, extended_defaults) simples | null default_tys = [] | otherwise @@ -1077,11 +1083,6 @@ findDefaultableGroups (default_tys, extended_defaults) wanteds , defaultable_tyvar tv , defaultable_classes (map sndOf3 group) ] where - simples = approximateWC True wanteds - -- True: for the purpose of defaulting we don't care - -- about shape or enclosing equalities - -- See (W3) in Note [ApproximateWC] in GHC.Tc.Types.Constraint - (unaries, non_unaries) = partitionWith find_unary (bagToList simples) unary_groups = equivClasses cmp_tv unaries ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -1824,6 +1824,10 @@ type ApproxWC = ( Bag Ct -- Free quantifiable constraints -- See (DP1) in Note [decideAndPromoteTyVars] in GHC.Tc.Solver approximateWC :: Bool -> WantedConstraints -> Bag Ct approximateWC include_non_quantifiable cts + | any insolubleWantedCt (wc_simple cts) + = -- See (W5) in Note [ApproximateWC] + emptyCts + | otherwise = fst (approximateWCX include_non_quantifiable cts) approximateWCX :: Bool -> WantedConstraints -> ApproxWC @@ -1861,7 +1865,7 @@ approximateWCX include_non_quantifiable wc -- There can be (insoluble) Given constraints in wc_simple, -- there so that we get error reports for unreachable code -- See `given_insols` in GHC.Tc.Solver.Solve.solveImplication - | insolubleCt ct = acc + | insolubleCt ct = acc -- See (W5) | pred_tvs `intersectsVarSet` skol_tvs = acc | include_non_quantifiable = add_to_quant | is_quantifiable encl_eqs (ctPred ct) = add_to_quant @@ -1973,6 +1977,18 @@ Wrinkle (W4) SPECIALISE pragmas: see (WFA4) in Note [Solving a Wanted forall-constraint]. But there we don't use approximateWC.) +Wrinkle (W5) + If an implication is insoluble we give up and return no constraints. We + do this locally, per-implication, so that sister soluble implications are + defulted normally. + + * For inferring types in `simplifyInfer` dhere is no point in inferring a + type with carefully chosen constraints if there is a type error anyway + + * For defaulting see Note [When to do type-class defaulting]. A tiresome + complication is that in the top-level WantedConstraints we have no + `ic_status` flag to look at, so we consult the `wc_simple` directly. + ------ Historical note ----------- There used to be a second caveat, driven by #8155 ===================================== testsuite/tests/overloadedstrings/should_fail/T25926.stderr ===================================== @@ -1,3 +1,11 @@ +T25926.hs:3:6: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘Eq a’ arising from the literal ‘0’ + Possible fix: + add (Eq a) to the context of + the inferred type of f :: () -> a -> () + • In the pattern: 0 + In an equation for ‘f’: f () 0 = () + T25926.hs:4:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘()’ with actual type ‘Char’ • 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)] • In the pattern: "HI" In an equation for ‘foo’: foo "HI" = True +T27124.hs:9:8: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘f0’ arising from a use of ‘pure’ + prevents the constraint ‘(Applicative f0)’ from being solved. + Relevant bindings include main :: f0 () (bound at T27124.hs:9:1) + Probable fix: use a type annotation to specify what ‘f0’ should be. + Potentially matching instances: + instance Applicative IO -- Defined in ‘GHC.Internal.Base’ + instance Applicative Maybe -- Defined in ‘GHC.Internal.Base’ + ...plus six others + ...plus one instance involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the expression: pure () + In an equation for ‘main’: main = pure () + ===================================== testsuite/tests/patsyn/should_fail/records-nofieldselectors.stderr ===================================== @@ -1,6 +1,6 @@ - records-nofieldselectors.hs:9:12: error: [GHC-88464] - Variable not in scope: x :: [a0] -> Int + Variable not in scope: x :: [Integer] -> Int Suggested fix: Notice that ‘x’ is a field selector that has been suppressed by NoFieldSelectors. + ===================================== testsuite/tests/typecheck/should_compile/T11254.stderr ===================================== @@ -1,9 +1,18 @@ - T11254.hs:16:10: warning: [GHC-18872] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘Frac Int’ with ‘Int’ arising from the superclasses of an instance declaration • In the instance declaration for ‘ID Rational’ +T11254.hs:16:10: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘Fractional Int’ + arising from the superclasses of an instance declaration + • In the instance declaration for ‘ID Rational’ + +T11254.hs:16:10: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘ID Int’ + arising from the superclasses of an instance declaration + • In the instance declaration for ‘ID Rational’ + T11254.hs:18:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘GHC.Internal.Real.Ratio Integer’ with ‘Int’ Expected: Rational -> Frac Rational @@ -13,3 +22,4 @@ T11254.hs:18:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] Instance sig: Rational -> Rational Class sig: Rational -> Frac Rational In the instance declaration for ‘ID Rational’ + ===================================== testsuite/tests/typecheck/should_compile/T15370.stderr ===================================== @@ -1,4 +1,3 @@ - T15370.hs:14:10: warning: [GHC-25897] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘n’ with ‘j’ Expected: n :~: j @@ -27,6 +26,17 @@ T15370.hs:20:13: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] no :: S r (bound at T15370.hs:18:7) right :: S r -> () (bound at T15370.hs:18:1) +T15370.hs:20:16: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Could not deduce ‘Num ()’ arising from a use of ‘+’ + from the context: y ~ x + bound by a pattern with constructor: + Refl :: forall {k} (a :: k). a :~: a, + in a case alternative + at T15370.hs:20:5-8 + • In the expression: no + _ + In a case alternative: Refl -> no + _ + In the expression: case mkRefl @x @y of Refl -> no + _ + T15370.hs:20:18: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: () • In the second argument of ‘(+)’, namely ‘_’ @@ -41,3 +51,4 @@ T15370.hs:20:18: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] mempty :: forall a. Monoid a => a maxBound :: forall a. Bounded a => a minBound :: forall a. Bounded a => a + ===================================== 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)] (and originally defined at ValidHoleFits.hs:4:12-22)) valid_hole_fits.hs:27:5: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] - • Found hole: _ :: t0 -> Maybe Integer - Where: ‘t0’ is an ambiguous type variable + • Found hole: _ :: Integer -> Maybe Integer • In the expression: _ 2 In an equation for ‘k’: k = _ 2 • Relevant bindings include @@ -87,6 +86,20 @@ valid_hole_fits.hs:27:5: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] (imported from ‘Prelude’ at valid_hole_fits.hs:3:1-40 (and originally defined in ‘GHC.Internal.Base’)) +valid_hole_fits.hs:30:5: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘a1’ arising from a use of ‘show’ + prevents the constraint ‘(Show a1)’ from being solved. + Probable fix: use a type annotation to specify what ‘a1’ should be. + Potentially matching instances: + instance (Show a, Show b) => Show (Either a b) + -- Defined in ‘GHC.Internal.Data.Either’ + instance Show Integer -- Defined in ‘GHC.Internal.Show’ + ...plus 26 others + ...plus 40 instances involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the expression: show _ + In an equation for ‘f’: f = show _ + valid_hole_fits.hs:30:10: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: a1 Where: ‘a1’ is an ambiguous type variable @@ -123,6 +136,20 @@ valid_hole_fits.hs:30:10: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] (imported from ‘Prelude’ at valid_hole_fits.hs:3:1-40 (and originally defined in ‘GHC.Internal.Float’)) +valid_hole_fits.hs:34:5: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘a0’ arising from a use of ‘show’ + prevents the constraint ‘(Show a0)’ from being solved. + Probable fix: use a type annotation to specify what ‘a0’ should be. + Potentially matching instances: + instance (Show a, Show b) => Show (Either a b) + -- Defined in ‘GHC.Internal.Data.Either’ + instance Show Integer -- Defined in ‘GHC.Internal.Show’ + ...plus 26 others + ...plus 35 instances involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the expression: show (_ (_ :: Bool)) + In an equation for ‘h’: h = show (_ (_ :: Bool)) + valid_hole_fits.hs:34:11: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)] • Found hole: _ :: Bool -> a0 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] • Could not deduce ‘a ><> b0’ from the context: a ><> b bound by the type signature for: - (<**) :: forall a b. (a ><> b) => a -> a -> () + (**>) :: forall a b. (a ><> b) => a -> a -> () at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous - • In the ambiguity check for ‘<**’ + • In the ambiguity check for ‘**>’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the class method: - (<**) :: forall a b. (a ><> b) => a -> a -> () + (**>) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ ClassOperator.hs:14:3: error: [GHC-39999] • Could not deduce ‘a ><> b0’ from the context: a ><> b bound by the type signature for: - (>**) :: forall a b. (a ><> b) => a -> a -> () + (**<) :: forall a b. (a ><> b) => a -> a -> () at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous - • In the ambiguity check for ‘>**’ + • In the ambiguity check for ‘**<’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the class method: - (>**) :: forall a b. (a ><> b) => a -> a -> () + (**<) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ ClassOperator.hs:14:3: error: [GHC-39999] • Could not deduce ‘a ><> b0’ from the context: a ><> b bound by the type signature for: - (**<) :: forall a b. (a ><> b) => a -> a -> () + (>**) :: forall a b. (a ><> b) => a -> a -> () at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous - • In the ambiguity check for ‘**<’ + • In the ambiguity check for ‘>**’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the class method: - (**<) :: forall a b. (a ><> b) => a -> a -> () + (>**) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ ClassOperator.hs:14:3: error: [GHC-39999] • Could not deduce ‘a ><> b0’ from the context: a ><> b bound by the type signature for: - (**>) :: forall a b. (a ><> b) => a -> a -> () + (<**) :: forall a b. (a ><> b) => a -> a -> () at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous - • In the ambiguity check for ‘**>’ + • In the ambiguity check for ‘<**’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the class method: - (**>) :: forall a b. (a ><> b) => a -> a -> () + (<**) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ ===================================== testsuite/tests/typecheck/should_fail/DoExpansion2.stderr ===================================== @@ -59,6 +59,20 @@ DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul In the expression: getVal 3 4 In a stmt of a 'do' block: Just x <- getVal 3 4 +DoExpansion2.hs:34:31: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘t0’ arising from the literal ‘4’ + prevents the constraint ‘(Num t0)’ from being solved. + Probable fix: use a type annotation to specify what ‘t0’ should be. + Potentially matching instances: + instance Num Integer -- Defined in ‘GHC.Internal.Num’ + instance Num Double -- Defined in ‘GHC.Internal.Float’ + ...plus three others + ...plus one instance involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the second argument of ‘getVal’, namely ‘4’ + In the expression: getVal 3 4 + In a stmt of a 'do' block: Just x <- getVal 3 4 + DoExpansion2.hs:39:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘[Char]’ with ‘Int’ Expected: Int ===================================== testsuite/tests/typecheck/should_fail/DoExpansion3.stderr ===================================== @@ -1,3 +1,24 @@ +DoExpansion3.hs:12:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘Num String’ arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘x’: x = 1 + In a stmt of a 'do' block: let x = 1 + +DoExpansion3.hs:13:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘a1’ arising from the literal ‘2’ + prevents the constraint ‘(Num a1)’ from being solved. + Relevant bindings include y :: a1 (bound at DoExpansion3.hs:13:16) + Probable fix: use a type annotation to specify what ‘a1’ should be. + Potentially matching instances: + instance Num Integer -- Defined in ‘GHC.Internal.Num’ + instance Num Double -- Defined in ‘GHC.Internal.Float’ + ...plus three others + ...plus one instance involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the expression: 2 + In an equation for ‘y’: y = 2 + In a stmt of a 'do' block: let y = 2 + DoExpansion3.hs:15:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘[Char]’ with ‘Int’ Expected: Int @@ -15,6 +36,38 @@ DoExpansion3.hs:18:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul In an equation for ‘y’: y = getChar 2 • Relevant bindings include y :: t (bound at DoExpansion3.hs:18:16) +DoExpansion3.hs:18:28: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘t0’ arising from the literal ‘2’ + prevents the constraint ‘(Num t0)’ from being solved. + Probable fix: use a type annotation to specify what ‘t0’ should be. + Potentially matching instances: + instance Num Integer -- Defined in ‘GHC.Internal.Num’ + instance Num Double -- Defined in ‘GHC.Internal.Float’ + ...plus three others + ...plus one instance involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the first argument of ‘getChar’, namely ‘2’ + In the expression: getChar 2 + In an equation for ‘y’: y = getChar 2 + +DoExpansion3.hs:19:20: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • Ambiguous type variable ‘a0’ arising from the literal ‘3’ + prevents the constraint ‘(Num a0)’ from being solved. + Relevant bindings include z :: a0 (bound at DoExpansion3.hs:19:16) + Probable fix: use a type annotation to specify what ‘a0’ should be. + Potentially matching instances: + instance Num Integer -- Defined in ‘GHC.Internal.Num’ + instance Num Double -- Defined in ‘GHC.Internal.Float’ + ...plus three others + ...plus one instance involving out-of-scope types + (use -fprint-potential-instances to see them all) + • In the expression: 3 + In an equation for ‘z’: z = 3 + In a stmt of a 'do' block: + let x = 1 + y = getChar 2 + z = 3 + DoExpansion3.hs:25:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match expected type ‘Int’ with actual type ‘Char’ • In the first argument of ‘(+)’, namely ‘x’ @@ -29,6 +82,12 @@ DoExpansion3.hs:27:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul do Just x <- getChar return x +DoExpansion3.hs:32:11: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘Num String’ arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘a’: a = 1 + In a stmt of a 'do' block: let a = 1 + DoExpansion3.hs:33:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)] • Couldn't match type ‘()’ with ‘Int’ Expected: IO Int @@ -44,3 +103,12 @@ DoExpansion3.hs:33:3: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault let a = 1 putStrLn $ a + "" +DoExpansion3.hs:33:16: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)] + • No instance for ‘Num String’ arising from a use of ‘+’ + • In the second argument of ‘($)’, namely ‘a + ""’ + In a stmt of a 'do' block: putStrLn $ a + "" + In the expression: + do let z :: Int = 3 + let a = 1 + putStrLn $ a + "" + ===================================== testsuite/tests/typecheck/should_fail/T22940.stderr ===================================== @@ -1,3 +1,3 @@ - T22940.hs:4:48: error: [GHC-88464] - Variable not in scope: a + Variable not in scope: a :: Integer + ===================================== testsuite/tests/typecheck/should_fail/T26823.stderr ===================================== @@ -1,7 +1,8 @@ T26823.hs:12:14: error: [GHC-25897] - • Couldn't match expected type ‘a0 -> a0 -> t’ with actual type ‘t’ + • Couldn't match expected type ‘Integer -> Integer -> t’ + with actual type ‘t’ ‘t’ is a rigid type variable bound by - the inferred type of rem :: a0 -> a0 -> t + the inferred type of rem :: Integer -> Integer -> t at T26823.hs:12:5-29 • In the expression: off `rem` vecAli In an equation for ‘rem’: !rem = off `rem` vecAli @@ -12,21 +13,13 @@ T26823.hs:12:14: error: [GHC-25897] !rem = off `rem` vecAli !start = if rem == 0 then off else off + (vecAli - rem) • Relevant bindings include - rem :: a0 -> a0 -> t (bound at T26823.hs:12:6) - off :: a0 (bound at T26823.hs:8:6) - vecAli :: a0 (bound at T26823.hs:10:6) - size :: a0 (bound at T26823.hs:9:6) + rem :: Integer -> Integer -> t (bound at T26823.hs:12:6) -T26823.hs:13:57: error: [GHC-27958] - • Couldn't match expected type ‘a0’ - with actual type ‘a0 -> a0 -> t0’ - • In the second argument of ‘(-)’, namely ‘rem’ +T26823.hs:13:57: error: [GHC-83865] + • Couldn't match expected type ‘Integer’ + with actual type ‘Integer -> Integer -> t0’ + • Probable cause: ‘rem’ is applied to too few arguments + In the second argument of ‘(-)’, namely ‘rem’ In the second argument of ‘(+)’, namely ‘(vecAli - rem)’ In the expression: off + (vecAli - rem) - • Relevant bindings include - start :: a0 (bound at T26823.hs:13:6) - rem :: forall {t}. a0 -> a0 -> t (bound at T26823.hs:12:6) - off :: a0 (bound at T26823.hs:8:6) - vecAli :: a0 (bound at T26823.hs:10:6) - size :: a0 (bound at T26823.hs:9:6) ===================================== testsuite/tests/typecheck/should_fail/T5691.stderr ===================================== @@ -1,10 +1,10 @@ - T5691.hs:24:10: error: [GHC-39999] - • No instance for ‘Alternative RecDecParser’ + • No instance for ‘Monad RecDecParser’ arising from the superclasses of an instance declaration • In the instance declaration for ‘MonadPlus RecDecParser’ T5691.hs:24:10: error: [GHC-39999] - • No instance for ‘Monad RecDecParser’ + • No instance for ‘Alternative RecDecParser’ arising from the superclasses of an instance declaration • In the instance declaration for ‘MonadPlus RecDecParser’ + ===================================== testsuite/tests/typecheck/should_fail/T7437.stderr ===================================== @@ -1,12 +1,3 @@ - -T7437.hs:14:13: error: [GHC-72771] - • The default type signature for put: - forall t. (Generic t, GPut (Rep t)) => t -> [()] - does not match its corresponding non-default type signature - • When checking the class method: - put :: forall a. Put a => a -> [()] - In the class declaration for ‘Put’ - T7437.hs:14:13: error: [GHC-39999] • Could not deduce ‘Put a0’ from the context: (Put a, Generic t, GPut (Rep t)) @@ -18,3 +9,12 @@ T7437.hs:14:13: error: [GHC-39999] To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the class method: put :: forall a. Put a => a -> [()] In the class declaration for ‘Put’ + +T7437.hs:14:13: error: [GHC-72771] + • The default type signature for put: + forall t. (Generic t, GPut (Rep t)) => t -> [()] + does not match its corresponding non-default type signature + • When checking the class method: + put :: forall a. Put a => a -> [()] + In the class declaration for ‘Put’ + ===================================== testsuite/tests/typecheck/should_fail/tcfail019.stderr ===================================== @@ -1,10 +1,10 @@ - tcfail019.hs:18:10: error: [GHC-39999] - • No instance for ‘B [a]’ + • No instance for ‘C [a]’ arising from the superclasses of an instance declaration • In the instance declaration for ‘D [a]’ tcfail019.hs:18:10: error: [GHC-39999] - • No instance for ‘C [a]’ + • No instance for ‘B [a]’ arising from the superclasses of an instance declaration • In the instance declaration for ‘D [a]’ + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2286d58c40bba550efdf12b2870b66... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2286d58c40bba550efdf12b2870b66... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Peyton Jones (@simonpj)