UndecidableInstances also allows flexible contexts
When I say
module Bug where
data T
instance Eq Int => Eq T
I get
Bug.hs:5:10: error:
• Non type-variable argument in the constraint: Eq Int
(Use FlexibleContexts to permit this)
• In the instance declaration for ‘Eq T’
Good so far. Now, just because I never like to be predictable, I add {-# LANGUAGE UndecidableInstances #-}
. Lo, the program is accepted.
Why? I think we should indeed require FlexibleContexts
here.
Once we nail the design, the fix is easy: just remove undecidable_ok
from this line in GHC.Tc.Validity.check_class_pred
:
InstDeclCtxt {} -> checkValidClsArgs (flexible_contexts || undecidable_ok) cls tys