#7173: Unnecessary constraints in inferred type
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.6.1-rc1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: GHC rejects valid program
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Changes (by Deewiant):
* failure: None/Unknown => GHC rejects valid program
* version: 7.4.2 => 7.6.1-rc1
Comment:
Reduced test case:
{{{
module Bug7173 where
data Binder b = Guess b
data TT n = Bind (Binder (TT n))
se p (Bind b) = sb b
sb (Guess t) = se 0 t
}}}
It works fine with 7.4.2 but fails with 7.6.1-rc1, inferring a spurious
`Num a` constraint for `sb` without referring to `a` at all:
{{{
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.2
$ ghc -S Bug7173.hs
$ ghc-7.6.0.20120810 --version
The Glorious Glasgow Haskell Compilation System, version 7.6.0.20120810
$ ghc-7.6.0.20120810 -S Bug7173.hs
Bug7173.hs:7:1:
Could not deduce (Num a0) arising from the ambiguity check for `sb'
from the context (Num a)
bound by the inferred type for `sb': Num a => Binder (TT t1) -> t
at Bug7173.hs:(7,1)-(8,21)
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
When checking that `sb'
has the inferred type `forall t t1 a. Num a => Binder (TT t1) -> t'
Probable cause: the inferred type is ambiguous
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7173#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs