Fix Trac #10519
authorThomas Winant <thomas.winant@cs.kuleuven.be>
Fri, 3 Jul 2015 17:35:29 +0000 (19:35 +0200)
committerBen Gamari <ben@smart-cactus.org>
Fri, 3 Jul 2015 20:36:59 +0000 (22:36 +0200)
Look through nested foralls when checking the validity of a partial type
signature. The combination of D836 and D613 prompts this change.

Test Plan: The test T10519 must pass

Reviewers: simonpj, alanz, austin

Reviewed By: simonpj, alanz, austin

Subscribers: thomie, bgamari

Differential Revision: https://phabricator.haskell.org/D994

GHC Trac Issues: #10519

compiler/rename/RnTypes.hs
testsuite/tests/partial-sigs/should_compile/T10519.hs [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/T10519.stderr [new file with mode: 0644]
testsuite/tests/partial-sigs/should_compile/all.T

index 3766ed1..705ca55 100644 (file)
@@ -554,7 +554,7 @@ rnLHsTypeWithWildCards doc ty
   = do { -- When there is a wild card at the end of the context, remove it and
          -- add its location as the extra-constraints wild card in the
          -- HsForAllTy.
-         let ty' = extractExtraCtsWc `fmap` ty
+         let ty' = extractExtraCtsWc `fmap` flattenTopLevelLHsForAllTy ty
 
        ; checkValidPartialType doc ty'
 
diff --git a/testsuite/tests/partial-sigs/should_compile/T10519.hs b/testsuite/tests/partial-sigs/should_compile/T10519.hs
new file mode 100644 (file)
index 0000000..66a59a7
--- /dev/null
@@ -0,0 +1,6 @@
+{-# LANGUAGE ExplicitForAll #-}
+{-# LANGUAGE PartialTypeSignatures #-}
+module T10519 where
+
+foo :: forall a. _ => a -> a -> Bool
+foo x y = x == y
diff --git a/testsuite/tests/partial-sigs/should_compile/T10519.stderr b/testsuite/tests/partial-sigs/should_compile/T10519.stderr
new file mode 100644 (file)
index 0000000..254292f
--- /dev/null
@@ -0,0 +1,4 @@
+
+T10519.hs:5:18: warning:
+    Found hole â€˜_’ with inferred constraints: Eq a
+    In the type signature for â€˜foo’: _ => a -> a -> Bool
index 56f1045..e649472 100644 (file)
@@ -48,3 +48,4 @@ test('UncurryNamed', normal, compile, ['-ddump-types -fno-warn-partial-type-sign
 test('WarningWildcardInstantiations', normal, compile, ['-ddump-types'])
 test('T10403', normal, compile, [''])
 test('T10438', normal, compile, [''])
+test('T10519', normal, compile, [''])