Reject bad 'deriving' directives (fixes Trac #5287)
The 'deriving' mechanism that infers the context for an instance declarations was going into a loop, as a result of an instance like instance C a b => D [a] where the 'b' isn't mentioned in the head. This patch identifies those cases. I also needed to make TcErrors generate a suitable error message. On the way I improved the reporting of "ambiguous" variables; for example arrowfail001 now generates a better message.
Showing with 91 additions and 89 deletions