
#14397: For type error involving inferred types, show source of the type -------------------------------------+------------------------------------- Reporter: max630 | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider the code: {{{#!hs a = 42 b = a . "hello" }}} The type Error is (ghc-8.2.1): {{{ TestTypes.hs:3:5: error: • Couldn't match expected type ‘b0 -> c’ with actual type ‘Integer’ • In the first argument of ‘(.)’, namely ‘a’ In the expression: a . "hello" In an equation for ‘b’: b = a . "hello" • Relevant bindings include b :: a -> c (bound at TestTypes.hs:3:1) | 3 | b = a . "hello" | ^ TestTypes.hs:3:9: error: • Couldn't match expected type ‘a -> b0’ with actual type ‘[Char]’ • In the second argument of ‘(.)’, namely ‘"hello"’ In the expression: a . "hello" In an equation for ‘b’: b = a . "hello" • Relevant bindings include b :: a -> c (bound at TestTypes.hs:3:1) | 3 | b = a . "hello" | ^^^^^^^ }}} Actually, the real mistake may be in line 1, where `a` is inferred as of type `Integer`, while it probably was not meant to. But that location is not reported to the error. As you can guess, in real code location where the unexpected type is inferred for a binding is not that obvious to find. Suggestion: track locations where bindings' types are inferred, and in case of type error involvin the bindings, add them to the "Relevant bindings" section, or otherwise show it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14397 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler