[GHC] #12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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: -------------------------------------+------------------------------------- The following code snippet (using the [https://hackage.haskell.org/package /ref-tf ref-tf library]) is well-typed, and GHC is fine with it: {{{#!hs import Control.Monad -- comment this out to cause error import Control.Monad.Ref main :: IO () main = newRef (pure ()) >>= join . readRef }}} However, if one comments out the first line, then GHC treats `join` as a typed hole due to #10569, but fails to infer its type, causing errors: {{{ test.hs:10:8-23: error: … • Couldn't match type ‘Ref m0’ with ‘GHC.IORef.IORef’ ... test.hs:10:29-32: error: … Variable not in scope: join :: m0 (f0 ()) -> IO () }}} By default the not-in-scope error is reported, but if `-fdefer-typed- holes` is in effect, only the type error is reported leaving the user (at least me) puzzled. Not-in-scope errors should ''always'' be reported. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.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: | -------------------------------------+------------------------------------- Description changed by ertes: @@ -1,2 +1,1 @@ - The following code snippet (using the [https://hackage.haskell.org/package - /ref-tf ref-tf library]) is well-typed, and GHC is fine with it: + The following code snippet is well-typed, and GHC is fine with it: @@ -5,0 +4,2 @@ + {-# LANGUAGE TypeFamilies #-} + @@ -6,1 +7,11 @@ - import Control.Monad.Ref + import Data.IORef + + class MonadRef m where + type Ref m :: * -> * + newRef :: a -> m (Ref m a) + readRef :: Ref m a -> m a + + instance MonadRef IO where + type Ref IO = IORef + newRef = newIORef + readRef = readIORef @@ -12,2 +23,3 @@ - However, if one comments out the first line, then GHC treats `join` as a - typed hole due to #10569, but fails to infer its type, causing errors: + However, if one removes the import of `Control.Monad`, then GHC treats + `join` as a typed hole due to #10569, but fails to infer its type, causing + errors: @@ -16,2 +28,2 @@ - test.hs:10:8-23: error: … - • Couldn't match type ‘Ref m0’ with ‘GHC.IORef.IORef’ + test.hs:17:8-23: error: … + • Couldn't match type ‘Ref m0’ with ‘IORef’ @@ -19,1 +31,1 @@ - test.hs:10:29-32: error: … + test.hs:17:29-32: error: … @@ -24,2 +36,2 @@ - holes` is in effect, only the type error is reported leaving the user (at - least me) puzzled. + holes` is in effect, only the type error is reported and the scope error + just vanishes, leaving the user (at least me) puzzled. New description: The following code snippet is well-typed, and GHC is fine with it: {{{#!hs {-# LANGUAGE TypeFamilies #-} import Control.Monad -- comment this out to cause error import Data.IORef class MonadRef m where type Ref m :: * -> * newRef :: a -> m (Ref m a) readRef :: Ref m a -> m a instance MonadRef IO where type Ref IO = IORef newRef = newIORef readRef = readIORef main :: IO () main = newRef (pure ()) >>= join . readRef }}} However, if one removes the import of `Control.Monad`, then GHC treats `join` as a typed hole due to #10569, but fails to infer its type, causing errors: {{{ test.hs:17:8-23: error: … • Couldn't match type ‘Ref m0’ with ‘IORef’ ... test.hs:17:29-32: error: … Variable not in scope: join :: m0 (f0 ()) -> IO () }}} By default the not-in-scope error is reported, but if `-fdefer-typed- holes` is in effect, only the type error is reported and the scope error just vanishes, leaving the user (at least me) puzzled. Not-in-scope errors should ''always'' be reported. -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * failure: None/Unknown => Incorrect warning at compile-time * related: => #12170 Comment: This can serve as a test case for #12170. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ak3n): * owner: => ak3n -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ak3n): * differential: => Phab:D2451 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Thanks for the patch, ak3n! I reviewed it, but found an easier way. I'll commit a patch shortly. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"efc0372a157eadeee58bbada77c64d53590e04af/ghc" efc0372a/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="efc0372a157eadeee58bbada77c64d53590e04af" Not-in-scope variables are always errors This fixes Trac #12406. A not-in-scope error shoudl be an error even if you have -fdefer-typed-holes. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | typecheck/should_fail/T12406 Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => typecheck/should_fail/T12406 Comment: Let's merge to 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | typecheck/should_fail/T12406 Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"6071ecf4ff7501c70456c1448fa2f78e91bc8078/ghc" 6071ecf4/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="6071ecf4ff7501c70456c1448fa2f78e91bc8078" Not-in-scope variables are always errors This fixes Trac #12406. A not-in-scope error shoudl be an error even if you have -fdefer-typed-holes. (cherry picked from commit efc0372a157eadeee58bbada77c64d53590e04af) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12406: New not-in-scope behaviour + deferred typed holes = disappearing error messages -------------------------------------+------------------------------------- Reporter: ertes | Owner: ak3n Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Incorrect | Test Case: warning at compile-time | typecheck/should_fail/T12406 Blocked By: | Blocking: Related Tickets: #12170 | Differential Rev(s): Phab:D2451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: => 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12406#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC