Fix #14045 by omitting an unnecessary check
authorRichard Eisenberg <rae@cs.brynmawr.edu>
Sat, 29 Jul 2017 01:43:38 +0000 (21:43 -0400)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Sat, 29 Jul 2017 15:31:56 +0000 (11:31 -0400)
commitd1ef223cfebd23c25489a4b0c67fbaa2f91c1ec6
tree8c23e6bd319d25c73e11b86bf0bdda81d3140375
parent9cfabbb5267e72b8017d8dc04d8580f73f425aa8
Fix #14045 by omitting an unnecessary check

Previously, we checked the number of patterns in a data instances
for all data families whose kind did not end in a kind variable.
But, of course, undersaturating instances can happen even without
the kind ending in a kind variable. So I've omitted the arity check.
Data families aren't as particular about their arity as type families
are (because data families can be undersaturated). Still, this change
degrades error messages when instances don't have the right arity;
now, instead of reporting a simple mismatch in the number of patterns,
GHC reports kind errors. The new errors are fully accurate, but perhaps
not as easy to work with. Still, with the new flexibility of allowing
data family instances with varying numbers of patterns, I don't see
a better way.

This commit also improves source fidelity in some error messages,
requiring more changes than really are necessary. But without these
changes, error messages around mismatched associated instance heads
were poor.

test cases: indexed-types/should_compile/T14045,
            indexed-types/should_fail/T14045a
14 files changed:
compiler/hsSyn/HsDecls.hs
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcValidity.hs
testsuite/tests/indexed-types/should_compile/T14045.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_compile/all.T
testsuite/tests/indexed-types/should_fail/SimpleFail1a.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail1b.stderr
testsuite/tests/indexed-types/should_fail/SimpleFail2a.stderr
testsuite/tests/indexed-types/should_fail/T14045a.hs [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/T14045a.stderr [new file with mode: 0644]
testsuite/tests/indexed-types/should_fail/all.T