Skip to content

FlexibleInstances / UndecidableInstances confusion

Consider the following code:

class Foo a

bar :: Foo a => Int
bar = 0

Compiling this code with no extensions correctly reports an error that bar is inherently ambiguous.

However, if I enable -XUndecidableInstances, the ambiguity error disappears, though I still cannot declare instance Foo a. On the other hand, if I enable -XFlexibleInstances, the ambiguity error remains, even though I can now declare instance Foo a.

I believe that the problem is due to confusion in the note [The ambiguity check for type signatures] in typecheck/TcMType.lhs. That note refers to UndecidableInstances where I believe it means FlexibleInstances. The code immediately below (line 1378, in function checkAmbiguity) also uses UndecidableInstances where it would seem to want FlexibleInstances.

I would fix this myself, but I don't feel confident enough in this wing of GHC to know this is the right change!

Trac metadata
Trac field Value
Version 7.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information