Fix two more bugs in partial signatures
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 9 Jan 2018 16:20:46 +0000 (16:20 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 9 Jan 2018 16:25:53 +0000 (16:25 +0000)
commit1577908f2a9db0fcf6f749d40dd75481015f5497
tree68ce132a2da4c3d914e3be219ddf8da2730f039c
parent448685c352542155f2e2361776c3b7f5e2a051ca
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.
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