Simon Peyton Jones pushed to branch wip/T23162-spj at Glasgow Haskell Compiler / GHC Commits: 8e2a2e57 by Simon Peyton Jones at 2025-08-16T09:51:36+01:00 Improved error messages from fundep changes - - - - - b8d5945f by Simon Peyton Jones at 2025-08-16T23:18:43+01:00 More wibbles to Outputable - - - - - 16 changed files: - compiler/GHC/Utils/Outputable.hs - testsuite/tests/deriving/should_fail/T3621.stderr - testsuite/tests/indexed-types/should_fail/T9662.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr - testsuite/tests/parser/should_fail/T20654a.stderr - testsuite/tests/partial-sigs/should_fail/T14040a.stderr - testsuite/tests/typecheck/no_skolem_info/T14040.stderr - testsuite/tests/typecheck/should_fail/FD3.stderr - testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr - testsuite/tests/typecheck/should_fail/T13506.stderr - testsuite/tests/typecheck/should_fail/T19415b.stderr - testsuite/tests/typecheck/should_fail/T5246.stderr - testsuite/tests/typecheck/should_fail/T5978.stderr - testsuite/tests/typecheck/should_fail/T8603.stderr - testsuite/tests/typecheck/should_fail/T9612.stderr Changes: ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -522,20 +522,22 @@ pprDeeper d = SDoc $ \ctx -> case sdocStyle ctx of _ -> runSDoc d ctx --- | Truncate a list that is longer than the default depth +-- | Trim the list to the length of the remaining depth count pprDeeperList :: ([SDoc] -> SDoc) -> [SDoc] -> SDoc pprDeeperList f ds | null ds = f [] | otherwise = SDoc work where - -- Trim the list to the length of the remaining depth count - work ctx@SDC{ sdocStyle=PprUser _ depth _ } - | Just list_elts_to_print + work ctx@SDC{ sdocStyle=PprUser q depth c } + | Just n_remaining <- case depth of DefaultDepth -> Just (sdocDefaultDepth ctx) PartWay n -> Just n AllTheWay -> Nothing - = runSDoc (f (trim list_elts_to_print ds)) ctx + = runSDoc (f (trim n_remaining ds)) + -- Trim the length of the list + (ctx { sdocStyle = PprUser q (PartWay (n_remaining - 1)) c }) + -- ..and go deeper as we step inside the list elements work other_ctx = runSDoc (f ds) other_ctx ===================================== testsuite/tests/deriving/should_fail/T3621.stderr ===================================== @@ -1,15 +1,9 @@ -T3621.hs:24:43: error: [GHC-25897] - • Couldn't match type ‘s’ with ‘state’ - arising from a functional dependency between: - constraint ‘MonadState state (State s)’ - arising from the 'deriving' clause of a data type declaration - instance ‘MonadState s1 (State s1)’ at T3621.hs:21:10-31 - ‘s’ is a rigid type variable bound by - the deriving clause for ‘MonadState state (WrappedState s)’ - at T3621.hs:24:43-58 - ‘state’ is a rigid type variable bound by - the deriving clause for ‘MonadState state (WrappedState s)’ - at T3621.hs:24:43-58 +T3621.hs:24:43: error: [GHC-39999] + • No instance for ‘MonadState state (State s)’ + arising from the 'deriving' clause of a data type declaration + Possible fix: + use a standalone 'deriving instance' declaration, + so you can specify the instance context yourself • When deriving the instance for (MonadState state (WrappedState s)) ===================================== testsuite/tests/indexed-types/should_fail/T9662.stderr ===================================== @@ -1,12 +1,12 @@ T9662.hs:49:8: error: [GHC-25897] - • Couldn't match type ‘n’ with ‘Int’ + • Couldn't match type ‘k’ with ‘Int’ Expected: Exp (((sh :. k) :. m) :. n) -> Exp (((sh :. m) :. n) :. k) Actual: Exp (Tuple (((Atom a0 :. Atom Int) :. Atom Int) :. Atom Int)) -> Exp (Plain (((Unlifted (Atom a0) :. Exp Int) :. Exp Int) :. Exp Int)) - ‘n’ is a rigid type variable bound by + ‘k’ is a rigid type variable bound by the type signature for: test :: forall sh k m n. Shape (((sh :. k) :. m) :. n) -> Shape (((sh :. m) :. n) :. k) ===================================== testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr ===================================== @@ -1,9 +1,9 @@ - -RecordDotSyntaxFail10.hs:40:11: error: [GHC-18872] - • Couldn't match type ‘Int’ with ‘[Char]’ +RecordDotSyntaxFail10.hs:40:11: error: [GHC-39999] + • No instance for ‘HasField "quux" Quux String’ • In the second argument of ‘($)’, namely ‘a {foo.bar.baz.quux}’ In a stmt of a 'do' block: print $ a {foo.bar.baz.quux} In the expression: - do let a = ... + do let a = Foo {foo = Bar {bar = ...}} let quux = "Expecto patronum!" print $ a {foo.bar.baz.quux} + ===================================== testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr ===================================== @@ -1,13 +1,10 @@ - -RecordDotSyntaxFail13.hs:26:11: error: [GHC-18872] - • Couldn't match type ‘Int’ with ‘Foo -> Int’ - arising from a functional dependency between: - constraint ‘HasField "foo" Foo (Foo -> Int)’ - arising from a record update - instance ‘HasField "foo" Foo Int’ - at RecordDotSyntaxFail13.hs:21:10-31 +RecordDotSyntaxFail13.hs:26:11: error: [GHC-39999] + • No instance for ‘HasField "foo" Foo (Foo -> Int)’ + arising from a record update + (maybe you haven't applied a function to enough arguments?) • In the second argument of ‘($)’, namely ‘a {foo}’ In a stmt of a 'do' block: print $ a {foo} In the expression: - do let a = ... + do let a = Foo {foo = 12} print $ a {foo} + ===================================== testsuite/tests/parser/should_fail/T20654a.stderr ===================================== @@ -1,12 +1,10 @@ - -T20654a.hs:7:9: error: [GHC-18872] - • Couldn't match type: forall a. a -> a - with: Int -> Int - arising from a functional dependency between constraints: - ‘?poly::Int -> Int’ - arising from a use of implicit parameter ‘?poly’ at T20654a.hs:7:9-13 - ‘?poly::forall a. a -> a’ - arising from the type signature for: - foo :: (?poly::forall a. a -> a) => Int -> Int at T20654a.hs:6:1-48 +T20654a.hs:7:9: error: [GHC-91416] + • Could not deduce ‘?poly::Int -> Int’ + arising from a use of implicit parameter ‘?poly’ + from the context: ?poly::forall a. a -> a + bound by the type signature for: + foo :: (?poly::forall a. a -> a) => Int -> Int + at T20654a.hs:6:1-48 • In the expression: ?poly x In an equation for ‘foo’: foo x = ?poly x + ===================================== testsuite/tests/partial-sigs/should_fail/T14040a.stderr ===================================== @@ -1,6 +1,6 @@ T14040a.hs:26:46: error: [GHC-46956] - • Couldn't match kind ‘k0’ with ‘WeirdList z’ - Expected kind ‘WeirdList k0’, + • Couldn't match kind ‘k1’ with ‘WeirdList z’ + Expected kind ‘WeirdList k1’, but ‘xs’ has kind ‘WeirdList (WeirdList z)’ because kind variable ‘z’ would escape its scope This (rigid, skolem) kind variable is bound by @@ -24,8 +24,8 @@ T14040a.hs:26:46: error: [GHC-46956] -> p _ wl T14040a.hs:27:27: error: [GHC-46956] - • Couldn't match kind ‘k1’ with ‘z’ - Expected kind ‘WeirdList k1’, + • Couldn't match kind ‘k0’ with ‘z’ + Expected kind ‘WeirdList k0’, but ‘WeirdCons x xs’ has kind ‘WeirdList z’ because kind variable ‘z’ would escape its scope This (rigid, skolem) kind variable is bound by ===================================== testsuite/tests/typecheck/no_skolem_info/T14040.stderr ===================================== @@ -1,6 +1,6 @@ T14040.hs:27:46: error: [GHC-46956] - • Couldn't match kind ‘k0’ with ‘WeirdList z’ - Expected kind ‘WeirdList k0’, + • Couldn't match kind ‘k1’ with ‘WeirdList z’ + Expected kind ‘WeirdList k1’, but ‘xs’ has kind ‘WeirdList (WeirdList z)’ because kind variable ‘z’ would escape its scope This (rigid, skolem) kind variable is bound by @@ -24,8 +24,8 @@ T14040.hs:27:46: error: [GHC-46956] -> p _ wl T14040.hs:28:27: error: [GHC-46956] - • Couldn't match kind ‘k1’ with ‘z’ - Expected kind ‘WeirdList k1’, + • Couldn't match kind ‘k0’ with ‘z’ + Expected kind ‘WeirdList k0’, but ‘WeirdCons x xs’ has kind ‘WeirdList z’ because kind variable ‘z’ would escape its scope This (rigid, skolem) kind variable is bound by ===================================== testsuite/tests/typecheck/should_fail/FD3.stderr ===================================== @@ -1,15 +1,5 @@ - -FD3.hs:15:15: error: [GHC-25897] - • Couldn't match type ‘a’ with ‘(String, a)’ - arising from a functional dependency between: - constraint ‘MkA (String, a) a’ arising from a use of ‘mkA’ - instance ‘MkA a1 a1’ at FD3.hs:12:10-16 - ‘a’ is a rigid type variable bound by - the type signature for: - translate :: forall a. (String, a) -> A a - at FD3.hs:14:1-31 +FD3.hs:15:15: error: [GHC-39999] + • No instance for ‘MkA (String, a) a’ arising from a use of ‘mkA’ • In the expression: mkA a In an equation for ‘translate’: translate a = mkA a - • Relevant bindings include - a :: (String, a) (bound at FD3.hs:15:11) - translate :: (String, a) -> A a (bound at FD3.hs:15:1) + ===================================== testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr ===================================== @@ -1,13 +1,10 @@ - -FDsFromGivens2.hs:15:15: error: [GHC-18872] - • Couldn't match type ‘Char’ with ‘[a]’ - arising from a functional dependency between constraints: - ‘C Char [a]’ arising from a use of ‘f’ at FDsFromGivens2.hs:15:15 - ‘C Char Char’ - arising from a pattern with constructor: - KCC :: C Char Char => () -> KCC, - in an equation for ‘bar’ at FDsFromGivens2.hs:15:6-10 +FDsFromGivens2.hs:15:15: error: [GHC-39999] + • Could not deduce ‘C Char [a]’ arising from a use of ‘f’ + from the context: C Char Char + bound by a pattern with constructor: + KCC :: C Char Char => () -> KCC, + in an equation for ‘bar’ + at FDsFromGivens2.hs:15:6-10 • In the expression: f In an equation for ‘bar’: bar (KCC _) = f - • Relevant bindings include - bar :: KCC -> a -> a (bound at FDsFromGivens2.hs:15:1) + ===================================== testsuite/tests/typecheck/should_fail/T13506.stderr ===================================== @@ -1,8 +1,6 @@ - -T13506.hs:16:12: error: [GHC-18872] - • Couldn't match type ‘Char’ with ‘()’ - arising from a functional dependency between: - constraint ‘FunDep [Char] ()’ arising from a use of ‘singleton’ - instance ‘FunDep [a] a’ at T13506.hs:5:10-21 +T13506.hs:16:12: error: [GHC-39999] + • No instance for ‘FunDep [Char] ()’ + arising from a use of ‘singleton’ • In the expression: singleton () In an equation for ‘illTyped’: illTyped = singleton () + ===================================== testsuite/tests/typecheck/should_fail/T19415b.stderr ===================================== @@ -1,8 +1,6 @@ - -T19415b.hs:15:8: error: [GHC-18872] - • Couldn't match type ‘Int’ with ‘Char’ - arising from a functional dependency between: - constraint ‘Ping (T a0) (T b) Char’ arising from a use of ‘foo’ - instance ‘Ping (T a) (T b1) Int’ at T19415b.hs:12:10-53 +T19415b.hs:15:8: error: [GHC-39999] + • No instance for ‘Ping (T a0) (T b0) Char’ + arising from a use of ‘foo’ • In the expression: foo 'c' MkT In an equation for ‘loop’: loop = foo 'c' MkT + ===================================== testsuite/tests/typecheck/should_fail/T5246.stderr ===================================== @@ -1,10 +1,9 @@ - -T5246.hs:11:10: error: [GHC-18872] - • Couldn't match type ‘[Char]’ with ‘Int’ - arising from a functional dependency between constraints: - ‘?x::Int’ arising from a use of ‘foo’ at T5246.hs:11:10-12 - ‘?x::String’ - arising from the implicit-parameter binding for ?x at T5246.hs:(10,7)-(11,12) +T5246.hs:11:10: error: [GHC-91416] + • Could not deduce ‘?x::Int’ arising from a use of ‘foo’ + from the context: ?x::String + bound by the implicit-parameter binding for ?x + at T5246.hs:(10,7)-(11,12) • In the expression: foo In the expression: let ?x = "hello" in foo In an equation for ‘bar’: bar = let ?x = "hello" in foo + ===================================== testsuite/tests/typecheck/should_fail/T5978.stderr ===================================== @@ -1,8 +1,5 @@ - -T5978.hs:22:11: error: [GHC-18872] - • Couldn't match type ‘Bool’ with ‘Char’ - arising from a functional dependency between: - constraint ‘C Double Char’ arising from a use of ‘polyBar’ - instance ‘C Double Bool’ at T5978.hs:8:10-22 +T5978.hs:22:11: error: [GHC-39999] + • No instance for ‘C Double Char’ arising from a use of ‘polyBar’ • In the expression: polyBar id monoFoo In an equation for ‘monoBar’: monoBar = polyBar id monoFoo + ===================================== testsuite/tests/typecheck/should_fail/T8603.stderr ===================================== @@ -3,8 +3,8 @@ T8603.hs:33:17: error: [GHC-18872] When matching types m0 :: * -> * [a2] :: * - Expected: [a2] -> StateT s RV a1 - Actual: t0 m0 (StateT s RV a1) + Expected: [a2] -> StateT s RV a0 + Actual: t0 m0 (StateT s RV a0) • The function ‘lift’ is applied to two visible arguments, but its type ‘(Control.Monad.Trans.Class.MonadTrans t, Monad m) => m a -> t m a’ ===================================== testsuite/tests/typecheck/should_fail/T9612.stderr ===================================== @@ -1,11 +1,11 @@ - -T9612.hs:16:9: error: [GHC-18872] - • Couldn't match type: [(Int, a)] - with: (Int, a) - arising from a functional dependency between: - constraint ‘MonadWriter (Int, a) (WriterT [(Int, a)] Identity)’ - arising from a use of ‘tell’ - instance ‘MonadWriter w (WriterT w m)’ at T9612.hs:20:10-59 +T9612.hs:16:9: error: [GHC-39999] + • Could not deduce ‘MonadWriter + (Int, a) (WriterT [(Int, a)] Identity)’ + arising from a use of ‘tell’ + from the context: Eq a + bound by the type signature for: + f :: forall a. Eq a => a -> (Int, a) -> Writer [(Int, a)] (Int, a) + at T9612.hs:13:1-57 • In a stmt of a 'do' block: tell (n, x) In the expression: do tell (n, x) @@ -14,8 +14,4 @@ T9612.hs:16:9: error: [GHC-18872] f y (n, x) = do tell (n, x) return (1, y) - • Relevant bindings include - x :: a (bound at T9612.hs:14:8) - y :: a (bound at T9612.hs:14:3) - f :: a -> (Int, a) -> Writer [(Int, a)] (Int, a) - (bound at T9612.hs:14:1) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/164590b57b9bd0ff7f18bb0bef2ed53... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/164590b57b9bd0ff7f18bb0bef2ed53... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)