[GHC] #10968: Type hole cause bad type checking
GHC
ghc-devs at haskell.org
Wed Oct 14 16:35:18 UTC 2015
#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
More information about the ghc-tickets
mailing list