Cyclic Type Class Hierarchy Produces <<loop>>
|Reported by:||jun0||Owned by:||simonpj|
|Component:||Compiler (Type checker)||Version:||7.4.1|
|Type of failure:||Incorrect result at runtime||Test Case:||T6117|
|Related Tickets:||Differential Rev(s):|
Description (last modified by simonpj)
If there is a cyclic class hierarchy like
class B a => Semigroup a where ...[[BR]] class Semigroup (Additive a) => Ring a where ...[[BR]] instance Ring a => Semigroup (Additive a) where ...[[BR]]
then uses of B's methods on (Additive a) in the method implementations of the third declaration instance Ring a => Semigroup (Additive a) will:
- be accepted by the compiler even in cases where B (Additive a) is not derivable.
- result in <<loop>>.
The attached program prints <<loop>> when compiled with GHC-7.2.1 or newer but prints 1234567890 when compiled with GHC-7.0.4 or older. I haven't had time to try out any revisions in between those two, but I did check that HEAD produces <<loop>> as well.
Change History (8)
Changed 4 years ago by jun0
comment:3 Changed 3 years ago by igloo
- Component changed from Compiler to Compiler (Type checker)
- Milestone set to 7.8.1
- Owner set to simonpj
- Test Case set to T6117