[commit: ghc] master: Fix #13833: accept type literals with no FlexibleInstances (42f3b53)
git at git.haskell.org
git at git.haskell.org
Fri Jun 15 18:58:59 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/42f3b53b5bc4674e41f16de08094821fe1aaec00/ghc
>---------------------------------------------------------------
commit 42f3b53b5bc4674e41f16de08094821fe1aaec00
Author: Kirill Zaborsky <qrilka at gmail.com>
Date: Fri Jun 15 14:12:58 2018 -0400
Fix #13833: accept type literals with no FlexibleInstances
Test Plan: ./validate
Reviewers: bgamari, simonpj
Reviewed By: bgamari, simonpj
Subscribers: simonpj, rwbarton, thomie, carter
GHC Trac Issues: #13833
Differential Revision: https://phabricator.haskell.org/D4823
>---------------------------------------------------------------
42f3b53b5bc4674e41f16de08094821fe1aaec00
compiler/typecheck/TcValidity.hs | 5 +++--
docs/users_guide/8.6.1-notes.rst | 5 +++++
testsuite/tests/typecheck/should_compile/T13833.hs | 12 ++++++++++++
testsuite/tests/typecheck/should_compile/all.T | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 84309db..6d866f7 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -1121,12 +1121,13 @@ tcInstHeadTyNotSynonym ty
tcInstHeadTyAppAllTyVars :: Type -> Bool
-- Used in Haskell-98 mode, for the argument types of an instance head
--- These must be a constructor applied to type variable arguments.
+-- These must be a constructor applied to type variable arguments
+-- or a type-level literal.
-- But we allow kind instantiations.
tcInstHeadTyAppAllTyVars ty
| Just (tc, tys) <- tcSplitTyConApp_maybe (dropCasts ty)
= ok (filterOutInvisibleTypes tc tys) -- avoid kinds
-
+ | LitTy _ <- ty = True -- accept type literals (Trac #13833)
| otherwise
= False
where
diff --git a/docs/users_guide/8.6.1-notes.rst b/docs/users_guide/8.6.1-notes.rst
index 147558e..4bc01c9 100644
--- a/docs/users_guide/8.6.1-notes.rst
+++ b/docs/users_guide/8.6.1-notes.rst
@@ -125,6 +125,11 @@ Language
This is now an error unless :extension:`PolyKinds` is enabled.
+- Type literals now could be used in type class instances without the extension
+ :extension:`FlexibleInstances`.
+
+ See :ghc-ticket:`13833`.
+
Compiler
~~~~~~~~
diff --git a/testsuite/tests/typecheck/should_compile/T13833.hs b/testsuite/tests/typecheck/should_compile/T13833.hs
new file mode 100644
index 0000000..266b00b
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T13833.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE DataKinds, KindSignatures #-}
+
+import GHC.TypeLits (Nat, Symbol)
+
+class A (n::Nat)
+instance A 0
+
+class B (s::Symbol)
+instance B "B"
+
+main :: IO ()
+main = return ()
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 8a7a7da..beaea5d 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -623,3 +623,4 @@ test('T15050', [expect_broken(15050)], compile, [''])
test('T14735', normal, compile, [''])
test('T15180', normal, compile, [''])
test('T15232', normal, compile, [''])
+test('T13833', normal, compile, [''])
\ No newline at end of file
More information about the ghc-commits
mailing list