Skip to content

checkValidInst: Don't expand synonyms when splitting sigma types

Ryan Scott requested to merge wip/T22570 into master

Previously, the checkValidInst function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using tcSplitSigmaTy to split apart the foralls and instance context. This is incorrect, however, as tcSplitSigmaTy expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously.

This patch introduces tcSplitSigmaTyNoView, a version of tcSplitSigmaTy that does not expand type synonyms, and uses it in checkValidInst.

Fixes #22570 (closed).

Merge request reports