Buglet in GHC.Tc.Module.checkBootTyCon
GHC.Tc.Module.checkBootTyCon` has this code:
checkBootTyCon :: Bool -> TyCon -> TyCon -> Maybe SDoc
checkBootTyCon is_boot tc1 tc2
...
| Just c1 <- tyConClass_maybe tc1
...
, Just env <- eqVarBndrs emptyRnEnv2 clas_tvs1 clas_tvs2
= let
eqSig (id1, def_meth1) (id2, def_meth2)
= ...
if is_boot
then check (liftEq eqDM def_meth1 def_meth2)
(text "The default methods associated with" <+> pname1 <+>
text "are different")
else check (subDM op_ty1 def_meth1 def_meth2)
(text "The default methods associated with" <+> pname1 <+>
text "are not compatible")
...
subDM t1 (Just (_, GenericDM t2)) (Just (_, VanillaDM))
= eqTypeX env t1 t2 <----------------------------- Yikes!
subDM _ (Just (_, GenericDM t1)) (Just (_, GenericDM t2))
= eqTypeX env t1 t2
The line labelled Yikes! is totally wrong. Here t1 and t2 both
come from tc1 and share a common name space. We should not rename t2
with tc2's renaming env!
The the fix is easy: replace eqTypeX env t1 t2 on that line with eqType t1 t2.
It would be better to rename the (confusingly numbered) t2 since it comes from tc1.
It is difficult to trigger this bug. It was revealed when working on !9343 (closed)
Edited by Simon Peyton Jones