[GHC] #14397: For type error involving inferred types, show source of the type
GHC
ghc-devs at haskell.org
Sat Oct 28 06:22:57 UTC 2017
#14397: For type error involving inferred types, show source of the type
-------------------------------------+-------------------------------------
Reporter: max630 | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Old description:
> Consider the code:
>
> {{{#!hs
> module TestTypes where
>
> a = 42
>
> b = a ++ "hello"
> }}}
>
> The type Error is (ghc-8.2.1):
>
> {{{
> TestTypes.hs:3:5: error:
> • No instance for (Num [Char]) arising from the literal ‘42’
> • In the expression: 42
> In an equation for ‘a’: a = 42
> |
> 3 | a = 42
> | ^^
> }}}
>
> Actually, the real mistake is in line 3, where `a` is inferred as of type
> `[Char]`, while it 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.
New description:
Consider the code:
{{{#!hs
module TestTypes where
a = 42
b = a ++ "hello"
}}}
The type Error is (ghc-8.2.1):
{{{
TestTypes.hs:3:5: error:
• No instance for (Num [Char]) arising from the literal ‘42’
• In the expression: 42
In an equation for ‘a’: a = 42
|
3 | a = 42
| ^^
}}}
Actually, the real mistake is in line 5, where `a` is inferred as of type
`[Char]`, while it 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.
--
Comment (by max630):
Fix the line reference in description
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14397#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list