[GHC] #10968: Type hole cause bad type checking

#10968: Type hole cause bad type checking -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: -------------------------------------+------------------------------------- I've tried to compile that incorrect code on ghc-7.10.2 linux x86_64: {{{#!hs import Control.Monad.Reader type Tst m = ReaderT () (ReaderT Int m) f :: Monad m => Tst m () f = return () f1 :: ReaderT () m () -> ReaderT () m () f1 ev = f >> _ >> ev main :: IO () main = print $ runReaderT (f1 (return ())) () }}} But тypechecker does not reject f1 and have that: {{{ [1 of 1] Compiling Main ( /home/ndtimofeev/tst.hs, /home/ndtimofeev/tst.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-unknown-linux): StgCmmEnv: variable not found $dFunctor_aYS local binds for: f_rsZ Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} If switch hole to undefined, i have normal typechecking error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10968 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10968: Type hole cause bad type checking -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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 mpickering): I can't reproduce this. How are you running ghc? {{{ GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( test.hs, interpreted ) test.hs:10:14: Found hole ‘_’ with type: ReaderT () m a0 Where: ‘m’ is a rigid type variable bound by the type signature for f1 :: ReaderT () m () -> ReaderT () m () at test.hs:9:7 ‘a0’ is an ambiguous type variable Relevant bindings include ev :: ReaderT () m () (bound at test.hs:10:4) f1 :: ReaderT () m () -> ReaderT () m () (bound at test.hs:10:1) In the second argument of ‘(>>)’, namely ‘_’ In the first argument of ‘(>>)’, namely ‘f >> _’ In the expression: f >> _ >> ev Failed, modules loaded: none. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10968#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10968: Type hole cause bad type checking -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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 ndtimofeev): I lost the line when the edit issue. {{{ $ ghc ~/tst.hs -fdefer-typed-holes -fno-warn-typed-holes }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10968#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10968: Type hole cause bad type checking -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 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: | -------------------------------------+------------------------------------- Old description:
I've tried to compile that incorrect code on ghc-7.10.2 linux x86_64:
{{{#!hs import Control.Monad.Reader
type Tst m = ReaderT () (ReaderT Int m)
f :: Monad m => Tst m () f = return ()
f1 :: ReaderT () m () -> ReaderT () m () f1 ev = f >> _ >> ev
main :: IO () main = print $ runReaderT (f1 (return ())) () }}}
But тypechecker does not reject f1 and have that:
{{{ [1 of 1] Compiling Main ( /home/ndtimofeev/tst.hs, /home/ndtimofeev/tst.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-unknown-linux): StgCmmEnv: variable not found $dFunctor_aYS local binds for: f_rsZ
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}}
If switch hole to undefined, i have normal typechecking error.
New description: I've tried to compile that incorrect code on ghc-7.10.2 linux x86_64: {{{#!hs import Control.Monad.Trans.Reader type Tst m = ReaderT () (ReaderT Int m) f :: Monad m => Tst m () f = return () f1 :: ReaderT () m () -> ReaderT () m () f1 ev = f >> _ >> ev main :: IO () main = print $ runReaderT (f1 (return ())) () }}} But тypechecker does not reject f1 and have that: {{{ [1 of 1] Compiling Main ( /home/ndtimofeev/tst.hs, /home/ndtimofeev/tst.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-unknown-linux): StgCmmEnv: variable not found $dFunctor_aYS local binds for: f_rsZ Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} If switch hole to undefined, i have normal typechecking error. -- Comment (by mpickering): OK, I can reproduce this now. With HEAD, I instead get the following errors.. which I can't comment any further on. I also changed the test to use Control.Monad.Trans.Reader instead of the mtl import. {{{ ~/Documents/haskell/ghc/inplace:./bin/ghc-stage2 test.hs -fdefer-typed- holes -fno-warn-typed-holes [1 of 1] Compiling Main ( test.hs, test.o ) test.hs:10:9: error: Couldn't match type ‘m’ with ‘ReaderT Int m0’ ‘m’ is a rigid type variable bound by the type signature for: f1 :: ReaderT () m () -> ReaderT () m () at test.hs:9:7 Expected type: ReaderT () m () Actual type: Tst m0 () Relevant bindings include ev :: ReaderT () m () (bound at test.hs:10:4) f1 :: ReaderT () m () -> ReaderT () m () (bound at test.hs:10:1) In the first argument of ‘(>>)’, namely ‘f’ In the first argument of ‘(>>)’, namely ‘f >> _’ test.hs:13:8: error: Ambiguous type variable ‘m1’ arising from a use of ‘print’ prevents the constraint ‘(Show (m1 ()))’ from being solved. Probable fix: use a type annotation to specify what ‘m1’ should be. These potential instances exist: instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’ instance (Show a, Show b, Show c) => Show (a, b, c) -- Defined in ‘GHC.Show’ ...plus 13 others (use -fprint-potential-instances to see them all) In the expression: print In the expression: print $ runReaderT (f1 (return ())) () In an equation for ‘main’: main = print $ runReaderT (f1 (return ())) () test.hs:13:32: error: Ambiguous type variable ‘m1’ arising from a use of ‘return’ prevents the constraint ‘(Monad m1)’ from being solved. Probable fix: use a type annotation to specify what ‘m1’ should be. These potential instances exist: instance [safe] Monad m => Monad (ReaderT r m) -- Defined in ‘Control.Monad.Trans.Reader’ instance Monad IO -- Defined in ‘GHC.Base’ instance Monad Maybe -- Defined in ‘GHC.Base’ ...plus three others (use -fprint-potential-instances to see them all) In the first argument of ‘f1’, namely ‘(return ())’ In the first argument of ‘runReaderT’, namely ‘(f1 (return ()))’ In the second argument of ‘($)’, namely ‘runReaderT (f1 (return ())) ()’ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10968#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10968: Type hole cause bad type checking -------------------------------------+------------------------------------- Reporter: ndtimofeev | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11274 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => duplicate * related: => #11274 Comment: This is a duplicate of #11274 and others (panic with `-fdefer-typed-holes` and missing instance). Already fixed in 8.0. I don't think adding another test to the testsuite is necessary. For fun, here is a smaller reproducer: {{{ module T10968 where f1 = fmap id _ }}} Thanks for reporting. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10968#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC