[GHC] #8649: Disambiguate Repeated Identifiers for data types in error messages

GHC ghc-devs at haskell.org
Sat Jan 4 17:42:58 UTC 2014


#8649: Disambiguate Repeated Identifiers for data types in error messages
------------------------------------+-------------------------------------
       Reporter:  agibiansky        |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.6.3
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 If, in an interactive context, you redefine a type, but then try to use
 functions for the previous definition, it will (as expected) give you an
 error message. The following code would trigger this in an interactive
 context:

 {{{
 data X = Y Int
 f (Y i) = i
 data X = Y Int | Z String
 f (Y 3)
 }}}

 However the error message is not very good:
 {{{
 Couldn't match expected type `:Interactive.X'
             with actual type `:Interactive.X'
 }}}

 This is very uninformative to the user if they do not understand what's
 going on.

 The following GHC API code can replicate this:
 {{{
   runDeclsWithLocation "Interactive.hs" 1 "data X = Y Int"
   runDeclsWithLocation "Asdf.hs" 2 "f (Y i) = i"
   runDeclsWithLocation "Bloop.hs" 3 "data X = Y Int | Z String"
   runStmtWithLocation  "Test.hs" 4 "f (Y 3)" RunToCompletion
 }}}

 Note that varying the location given to `runStmt` and `runDecls` (the
 string as well as the line number) seems to have no effect upon anything.
 I started out with just "<interactive>" but varied it to check - no effect
 on anything as far as I can tell.

 How can I make this error message more informative? I would ideally like
 something like
 {{{
 Couldn't match expected type `:Interactive1.X'
             with actual type `:Interactive5.X'
 }}}
 or really anything that caused these types to be visibly different.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8649>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list