Skip to content

Fix #16114 by adding a validity check to rnClsInstDecl

Ryan Scott requested to merge RyanGlScott/ghc:wip/T16114 into master

Commit 1c062b79 removed a validity check from rnLHsInstType (which rejects some ill-formed instances like A => B => C) under the rallying cry of simplifying code. While this commit had the best of intentions, it inadvertently made the error message for Eq a => Eq a => Eq (T a) hopelessly confusing, as documented in #16114 (closed).

This partially reverts 1c062b79 by restoring that same validity check (but placing it in rnClsInstDecl this time). Since rnLHsInstType is currently just a thin wrapper around rnHsSigType (and only has one call site), this patch also opts to just delete rnLHsInstType entirely. Finally, this adds a test case for Eq a => Eq a => Eq (T a) to ensure that this does not regress in the future.

Edited by Ryan Scott

Merge request reports