#5095: Incoherent instance for Prelude type class accepted without incoherent
instances option
----------------------------------------+-----------------------------------
Reporter: brunosoliveira | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.4.1
Component: Compiler (Type checker) | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: GHC accepts invalid
program
----------------------------------------+-----------------------------------
Comment(by simonpj@…):
commit 9d251f5ec83be41fdc3a7f1104ea8968fa9e5ebe
{{{
Author: Simon Peyton Jones <[email protected]>
Date: Wed Aug 3 16:22:06 2011 +0100
Fix a grevious error in InstEnv: Trac #5095
An claimed short-cut optimisation was actually an error.
The optimisation was this: when looking up (C a b), where
'a' and 'b' are type variables, we were returning [] immediately
if the instance environment had no instances of form (C a b).
Why? Because the thing being looked up definitely won't match
(C Int Bool), say.
BUT it will *unify* with (C Int Bool) and we care very much
about things it might unify with. If we neglect them we may
silently allow incoherent instance selection, and that is
exactly what happened in #5095.
The fix is easy: remove the "optimisation".
compiler/types/InstEnv.lhs | 45
++++++++++++++++---------------------------
1 files changed, 17 insertions(+), 28 deletions(-)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5095#comment:3>
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