[GHC] #8278: Improve error message when the same type is imported from two different library versions
#8278: Improve error message when the same type is imported from two different library versions ------------------------------------+------------------------------------- Reporter: Yuras | 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: | ------------------------------------+------------------------------------- When a package indirectly depends on different versions of the same library, ghc reports cryptic error: {{{ Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' }}} Error contains fully qualified type with package name and version only when the type is imported from different versions on the library, so looks like ghc knows what is wrong. Is it possible to add something like the next: {{{ Note: ByteString is imported from different package versions: bytestring-0.9.2.1 and bytestring-0.10.0.1 }}} It is inspired by a number of StackOverflow questions (e.g. http://stackoverflow.com/questions/12576817/couldnt-match-expected-type- with-actual-type-error-when-using-codec-bmp/12577025#12577025, http://stackoverflow.com/questions/18767086/bytestring-to-lazy-text-and- vice-versa/18769431?noredirect=1#comment27676563_18769431) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------ Reporter: Yuras | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by Yuras): * type: bug => feature request -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------ Reporter: Yuras | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by Yuras): And related request: in the same situation (two versions of the same library) when instance of class A for bytestring-0.9.2.1:Data.ByteString.Internal.ByteString is in scope, but the instance for ByteString is not in scope, is it possible to add a special note? Realworld case: http://stackoverflow.com/questions/11068272/acid-state- monadstate-instance-for-update -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------ Reporter: Yuras | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"2403fa102559e81d665838a62b2a5de3229a9783/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="2403fa102559e81d665838a62b2a5de3229a9783" Improve printing of errors when the tycons look the same See Trac #8278. Example new message: Couldn't match expected type ‛T8278a.Maybe’ with actual type ‛Maybe a0’ NB: ‛T8278a.Maybe’ is defined in ‛T8278a’ ‛Maybe’ is defined in ‛Data.Maybe’ in package ‛base’ In the first argument of ‛f’, namely ‛Nothing’ The "NB" is the new bit }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------ Reporter: Yuras | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"9ca32193a82218c18a633d1ae505248d65ef17a4/testsuite"]: {{{ #!CommitTicketReference repository="testsuite" revision="9ca32193a82218c18a633d1ae505248d65ef17a4" Wibbles following fix to Trac #8278 The error message for ghci052 and ghci053 are (still) terrible, because there is shadowing going on in the interactive context. But that's a separate matter. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------------------+------------------------- Reporter: Yuras | Owner: Type: feature request | Status: Priority: normal | closed Component: Compiler | Milestone: Resolution: fixed | Version: 7.6.3 Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Test Case: | Unknown/Multiple typecheck/should_fail/tcfail182 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Changes (by simonpj): * status: new => closed * testcase: => typecheck/should_fail/tcfail182 * resolution: => fixed Comment: Good idea. Much improved now I think: {{{ Couldn't match expected type ‛T8278a.Maybe’ with actual type ‛Maybe a0’ NB: ‛T8278a.Maybe’ is defined in ‛T8278a’ ‛Maybe’ is defined in ‛Data.Maybe’ in package ‛base’ In the first argument of ‛f’, namely ‛Nothing’ }}} However implementing the idea in Comment 2 is much harder. If you think it's important and/or you trip over it a lot in practice, please open a new ticket. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------------------+------------------------- Reporter: Yuras | Owner: Type: feature request | Status: Priority: normal | closed Component: Compiler | Milestone: Resolution: fixed | Version: 7.6.3 Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Test Case: | Unknown/Multiple typecheck/should_fail/tcfail182 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"322b48b92b93e1250b360d21873fa9f31c142403/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="322b48b92b93e1250b360d21873fa9f31c142403" Further improve the "same-occurrence" error messages (Trac #8278) Sometimes we actually have a good SrcSpan for the type constructor and reporting that is better than just reporting which module it was defined on }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------- Reporter: Yuras | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/tcfail182 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dmwit): Just wanted to pipe up and say I've just been hit by the problem in Comment 2. It seems it doesn't happen very often; but when it does happen it's quite confusing. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8278: Improve error message when the same type is imported from two different library versions -------------------------------------+------------------------------------- Reporter: Yuras | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/tcfail182 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): #9611 is the ticket for comment:2, I believe. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8278#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC