Skip to content
Snippets Groups Projects
Commit 75c29aa1 authored by sheaf's avatar sheaf Committed by Marge Bot
Browse files

Reject instance with non-class head in renamer

This commit modifies rnClsInstDecl so that, when renaming, we reject a class
instance declaration in which the head is not a class. Before this change, it
would get rejected in the type-checker, but that meant that the renamer could
emit unhelpful error messages, e.g.:

  data Foo m a
  instance Foo m where
    fmap _ x = case x of

would rather unhelpfully say:

    ‘fmap’ is not a (visible) method of class ‘Foo’

when of course 'Foo' is not even a class. We now reject the above program
with the following error message:

    Illegal instance for data type ‘Foo’.
    Instance heads must be of the form
      C ty_1 ... ty_n
    where ‘C’ is a class.

Fixes #22688
parent 4329f3b6
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment