[GHC] #14722: Error message points to wrong location

#14722: Error message points to wrong location -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.5 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect Unknown/Multiple | error/warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This rightly fails, but I have an issue with the error message. I think points to the visible type application eagerly.. rather than the type annotation `(f_xx :: ())`. {{{#!hs {-# Language RankNTypes, PolyKinds, GADTs, TypeApplications, ScopedTypeVariables #-} import Data.Kind newtype Limit :: (k -> Type) -> Type where Limit :: (forall xx. f xx) -> Limit f foo :: forall f a. Limit f -> f a foo (Limit (f_xx :: ())) = f_xx @a }}} gives {{{ $ ghci -ignore-dot-ghci /tmp/Test.hs GHCi, version 8.5.20180105: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/Test.hs, interpreted ) /tmp/Test.hs:9:28: error: • Cannot apply expression of type ‘()’ to a visible type argument ‘a’ • In the expression: f_xx @a In an equation for ‘foo’: foo (Limit (f_xx :: ())) = f_xx @a | 9 | foo (Limit (f_xx :: ())) = f_xx @a | ^^^^^^^ Failed, no modules loaded. Prelude> }}} I would have expected: {{{ /tmp/Test.hs:9:13: error: • Couldn't match expected type ‘()’ with actual type ‘f xx0’ • When checking that the pattern signature: () fits the type of its context: forall (xx :: k1). f xx In the pattern: f_xx :: () In the pattern: Limit (f_xx :: ()) • Relevant bindings include foo :: Limit f -> f a (bound at /tmp/Test.hs:9:1) }}} Thoughts -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14722 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14722: Error message points to wrong location -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: | TypeApplications Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => TypeApplications Comment: You're right. This is a consequence of the fact that (currently) GHC reports visible-type-application errors "eagerly", as soon as it encounters them, discarding all pending errors. In this case the error you want reported will be pending (in the constraints being gathered) but it never gets a chance to be reported. Richard: it'd be good to find a way to defer the visible-type-application error. But we don't have a way to do that yet. A `HoleCan` isn't right. A constraint `[W] () ~ forall a. ???` doesn't seem right because we have nothing to put for the `??`. I suppose we could invent a new kind of deferred error constraint, perhaps generalising `HoleCan`. See [wiki:TypeApplication] for a list of other VTA-related tickets; I have not checked but I bet that some are like this one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14722#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14722: Error message points to wrong location -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: | TypeApplications Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Yes, I think that's the right approach, in order to get this error to interact better with others. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14722#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14722: Error message points to wrong location -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.5 Resolution: | Keywords: | TypeApplications, DeferredErrors Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple error/warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: TypeApplications => TypeApplications, DeferredErrors -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14722#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC