Fix two more bugs in partial signatures
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 9 Jan 2018 16:20:46 +0000 (16:20 +0000)
committerBen Gamari <ben@smart-cactus.org>
Sun, 14 Jan 2018 22:07:22 +0000 (17:07 -0500)
commit3d2664e4d97fde24f4a70d3fd106618d41c55776
tree46320298f553a781d4633f6cee856fec3b818c73
parent0d40693654678e6a8ce8a63d198420c88e11dcff
Fix two more bugs in partial signatures

These were shown up by Trac #14643

Bug 1: if we had a single partial signature for
two functions
   f, g :: forall a. _ -> a
then we made two different SigTvs but with the sane Name.
This was jolly confusing and ultimately led to deeply bogus
results with Any's appearing in the resulting program. Yikes.
Fix: clone the quantified variables in TcSigs.tcInstSig (as
indeed its name suggests).

Bug 2: we were not eliminating duplicate/superclass constraints
in the partial signatures of a mutually recursive group.

Easy to fix: we are already doing dup/superclass elim in
TcSimplify.decideQuantification.  So we move the partial-sig
constraints there too.

(cherry picked from commit 1577908f2a9db0fcf6f749d40dd75481015f5497)
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcSigs.hs
compiler/typecheck/TcSimplify.hs
testsuite/tests/partial-sigs/should_compile/T14643.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T14643.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T14643a.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T14643a.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/all.T
testsuite/tests/partial-sigs/should_fail/T14040a.stderr
testsuite/tests/partial-sigs/should_fail/all.T