diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-01-09 16:20:46 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-01-09 16:25:53 +0000 |
commit | 1577908f2a9db0fcf6f749d40dd75481015f5497 (patch) | |
tree | 68ce132a2da4c3d914e3be219ddf8da2730f039c /testsuite | |
parent | 448685c352542155f2e2361776c3b7f5e2a051ca (diff) | |
download | haskell-1577908f2a9db0fcf6f749d40dd75481015f5497.tar.gz |
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.
Diffstat (limited to 'testsuite')
7 files changed, 41 insertions, 4 deletions
diff --git a/testsuite/tests/partial-sigs/should_compile/T14643.hs b/testsuite/tests/partial-sigs/should_compile/T14643.hs new file mode 100644 index 0000000000..b6de27db65 --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T14643.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE PartialTypeSignatures #-} + +module T14653 where + +af, ag :: (Num a,_) => a -> a +-- It's important that one signature covers both + +af y = ag y +ag x = af (x-1) diff --git a/testsuite/tests/partial-sigs/should_compile/T14643.stderr b/testsuite/tests/partial-sigs/should_compile/T14643.stderr new file mode 100644 index 0000000000..c5f204e799 --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T14643.stderr @@ -0,0 +1,8 @@ + +T14643.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] + • Found type wildcard ‘_’ standing for ‘()’ + • In the type signature: af :: (Num a, _) => a -> a + +T14643.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] + • Found type wildcard ‘_’ standing for ‘()’ + • In the type signature: ag :: (Num a, _) => a -> a diff --git a/testsuite/tests/partial-sigs/should_compile/T14643a.hs b/testsuite/tests/partial-sigs/should_compile/T14643a.hs new file mode 100644 index 0000000000..47ef519e37 --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T14643a.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE PartialTypeSignatures #-} + +module T14653a where + +af :: (Num a,_) => a -> a +af y = ag y + +ag :: (Num a,_) => a -> a +ag x = af (x-1) diff --git a/testsuite/tests/partial-sigs/should_compile/T14643a.stderr b/testsuite/tests/partial-sigs/should_compile/T14643a.stderr new file mode 100644 index 0000000000..1514ac92ed --- /dev/null +++ b/testsuite/tests/partial-sigs/should_compile/T14643a.stderr @@ -0,0 +1,8 @@ + +T14643a.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)] + • Found type wildcard ‘_’ standing for ‘()’ + • In the type signature: af :: (Num a, _) => a -> a + +T14643a.hs:8:14: warning: [-Wpartial-type-signatures (in -Wdefault)] + • Found type wildcard ‘_’ standing for ‘()’ + • In the type signature: ag :: (Num a, _) => a -> a diff --git a/testsuite/tests/partial-sigs/should_compile/all.T b/testsuite/tests/partial-sigs/should_compile/all.T index 0f4e425c8e..d13af5ca17 100644 --- a/testsuite/tests/partial-sigs/should_compile/all.T +++ b/testsuite/tests/partial-sigs/should_compile/all.T @@ -38,7 +38,7 @@ test('PatBind', normal, compile, ['-ddump-types -fno-warn-partial-type-signature # Bug test('PatBind2', normal, compile, ['-ddump-types -fno-warn-partial-type-signatures']) test('PatternSig', normal, compile, ['-ddump-types -fno-warn-partial-type-signatures']) -test('PatternSplice', normal, compile, ['-fno-warn-partial-type-signatures']) +test('PatternSplice', [req_interp, normal], compile, ['-fno-warn-partial-type-signatures']) test('Recursive', normal, compile, ['-ddump-types -fno-warn-partial-type-signatures']) test('ScopedNamedWildcards', normal, compile, ['-ddump-types -fno-warn-partial-type-signatures']) test('ScopedNamedWildcardsGood', normal, compile, ['-ddump-types -fno-warn-partial-type-signatures']) @@ -53,7 +53,7 @@ test('WarningWildcardInstantiations', normal, compile, ['-ddump-types']) test('SplicesUsed', [extra_files(['Splices.hs']), req_interp, omit_ways(prof_ways)], multimod_compile, ['SplicesUsed', config.ghc_th_way_flags]) -test('TypedSplice', [req_interp, normal], compile, ['']) +test('TypedSplice', normal, compile, ['']) test('T10403', normal, compile, ['']) test('T10438', normal, compile, ['']) test('T10519', normal, compile, ['']) @@ -71,3 +71,6 @@ test('T12845', normal, compile, ['']) test('T12844', normal, compile, ['']) test('T13482', normal, compile, ['']) test('T14217', normal, compile_fail, ['']) +test('T14643', normal, compile, ['']) +test('T14643a', normal, compile, ['']) + diff --git a/testsuite/tests/partial-sigs/should_fail/T14040a.stderr b/testsuite/tests/partial-sigs/should_fail/T14040a.stderr index b4f0e26822..ac9ad8a1bd 100644 --- a/testsuite/tests/partial-sigs/should_fail/T14040a.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T14040a.stderr @@ -21,7 +21,7 @@ T14040a.hs:34:8: error: -> Sing xs -> p (WeirdList z1) w1 xs -> p z1 w2 ('WeirdCons x xs)) - -> p a w3 wl’ + -> p a1 w3 wl’ to a visible type argument ‘(WeirdList z)’ • In the sixth argument of ‘pWeirdCons’, namely ‘(elimWeirdList @(WeirdList z) @xs @p xs pWeirdNil pWeirdCons)’ diff --git a/testsuite/tests/partial-sigs/should_fail/all.T b/testsuite/tests/partial-sigs/should_fail/all.T index b974ce8950..0f7496d1f5 100644 --- a/testsuite/tests/partial-sigs/should_fail/all.T +++ b/testsuite/tests/partial-sigs/should_fail/all.T @@ -3,7 +3,7 @@ test('AnnotatedConstraintNotForgotten', normal, compile_fail, ['']) test('Defaulting1MROff', normal, compile, ['']) test('ExtraConstraintsWildcardInExpressionSignature', normal, compile, ['']) test('ExtraConstraintsWildcardInPatternSignature', normal, compile_fail, ['']) -test('ExtraConstraintsWildcardInPatternSplice', normal, compile_fail, ['']) +test('ExtraConstraintsWildcardInPatternSplice', [req_interp, normal], compile_fail, ['']) test('ExtraConstraintsWildcardInTypeSpliceUsed', [extra_files(['ExtraConstraintsWildcardInTypeSplice.hs']), req_interp], multimod_compile_fail, |