Skip to content

Extended defaulting rules not used for super classes

Consider the following module

{-# LANGUAGE ExtendedDefaultRules #-}
module Bug4 where

class (Num a) => C a where
    f :: a -> a

instance C Integer where
    f = (+1)

x = show (f 5)

The type of x is

x :: (C a) => String

and since a is ambiguous the defaulting rules should be used. Since Num is a superclass of C the type variable should be defaulted to Integer. But instead we get an error.

Removing the Num superclass of C makes it work, since the type of x is

x ::: (Num a, C a) => String

and the defaulting kicks in as expected.

Trac metadata
Trac field Value
Version 6.10.1
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