Skip to content
  • Ryan Scott's avatar
    Don't mark closed type family equations as occurrences · d47324ce
    Ryan Scott authored and Marge Bot's avatar Marge Bot committed
    Previously, `rnFamInstEqn` would mark the name of the type/data
    family used in an equation as an occurrence, regardless of what sort
    of family it is. Most of the time, this is the correct thing to do.
    The exception is closed type families, whose equations constitute its
    definition and therefore should not be marked as occurrences.
    Overzealously counting the equations of a closed type family as
    occurrences can cause certain warnings to not be emitted, as observed
    in #18470.  See `Note [Type family equations and occurrences]` in
    `GHC.Rename.Module` for the full story.
    
    This fixes #18470 with a little bit of extra-casing in
    `rnFamInstEqn`. To accomplish this, I added an extra
    `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of
    `AssocTyFamInfo` and refactored the relevant call sites accordingly
    so that this information is propagated to `rnFamInstEqn`.
    
    While I was in town, I moved `wrongTyFamName`, which checks that the
    name of a closed type family matches the name in an equation for that
    family, from the renamer to the typechecker to avoid the need for an
    `ASSERT`. As an added bonus, this lets us simplify the details of
    `ClosedTyFamInfo` a bit.
    d47324ce