[GHC] #11464: Type casts cause confusing error

#11464: Type casts cause confusing error -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 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: -------------------------------------+------------------------------------- Try this {{{ instance Eq (Either a) }}} GHC HEAD gives {{{ Foo.hs:9:10: error: • Illegal instance declaration for ‘Eq (Either a)’ (All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type variables*, and each type variable appears at most once in the instance head. Use FlexibleInstances if you want to disable this.) • In the instance declaration for ‘Eq (Either a)’ Foo.hs:9:14: error: • Expecting one more argument to ‘Either a’ Expected a type, but ‘Either a’ has kind ‘* -> *’ • In the first argument of ‘Eq’, namely ‘Either a’ In the instance declaration for ‘Eq (Either a)’ }}} The second is right but the first is outright misleading. Reason: we elaborate to {{{ Eq (Either a |> g) }}} where `g` is a type-level kind cast; it's insoluble and gives rise to the second error. But the elaborated type confuses `checkValidInstHead`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11464 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11464: Type casts cause confusing error
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
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: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11464: Type casts cause confusing error -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T11464 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => typecheck/should_fail/T11464 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11464#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11464: Type casts cause confusing error -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T11464 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.0` in 76d8549d07df1fffa87a820cea1c556104ff382c. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11464#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11464: Type casts cause confusing error -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T11464 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): One could theoretically want `tcSplitCastedTyConApp_maybe` which is somewhat less crude, but I agree that this works. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11464#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC