diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-01-30 11:51:22 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-01-30 14:00:23 -0500 |
commit | 7363d5380e600e2ef868a069d5df6857d9e5c17e (patch) | |
tree | f6119aba56780edd79ce802fbab573b0966134fc /testsuite/tests/generics | |
parent | 2ec1c834ca1129b69f4dd3e2586d9f318cbb3fa6 (diff) | |
download | haskell-7363d5380e600e2ef868a069d5df6857d9e5c17e.tar.gz |
Check that a default type signature aligns with the non-default signature
Before, GHC was extremely permissive about the form a default type
signature could take on in a class declaration. Notably, it would accept
garbage like this:
class Monad m => MonadSupply m where
fresh :: m Integer
default fresh :: MonadTrans t => t m Integer
fresh = lift fresh
And then give an extremely confusing error message when you actually
tried to declare an empty instance of MonadSupply. We now do extra
validity checking of default type signatures to ensure that they align
with their non-default type signature counterparts. That is, a default
type signature is allowed to differ from the non-default one only in its
context - they must otherwise be alpha-equivalent.
Fixes #12918.
Test Plan: ./validate
Reviewers: goldfire, simonpj, austin, bgamari
Reviewed By: bgamari
Subscribers: mpickering, dfeuer, thomie
Differential Revision: https://phabricator.haskell.org/D2983
GHC Trac Issues: #12918
Diffstat (limited to 'testsuite/tests/generics')
-rw-r--r-- | testsuite/tests/generics/T10361b.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/testsuite/tests/generics/T10361b.hs b/testsuite/tests/generics/T10361b.hs index 6ecd99e644..e655c7c4c0 100644 --- a/testsuite/tests/generics/T10361b.hs +++ b/testsuite/tests/generics/T10361b.hs @@ -16,7 +16,9 @@ class Convert a where type instance Result a = GResult (Rep a) convert :: a -> Result a - default convert :: (Generic a, GConvert (Rep a)) => a -> GResult (Rep a) + default convert + :: (Generic a, GConvert (Rep a), Result a ~ GResult (Rep a)) + => a -> Result a convert x = gconvert (from x) instance Convert Float where |