summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Zaborsky <qrilka@gmail.com>2018-06-15 14:12:58 -0400
committerBen Gamari <ben@smart-cactus.org>2018-06-15 14:13:09 -0400
commit42f3b53b5bc4674e41f16de08094821fe1aaec00 (patch)
tree2c7d4355a4c1ecb90a2bece332ebac03a3c0fc71
parent7100850eebb1c1aec0aaabca08915bac8b90e188 (diff)
downloadhaskell-42f3b53b5bc4674e41f16de08094821fe1aaec00.tar.gz
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
-rw-r--r--compiler/typecheck/TcValidity.hs5
-rw-r--r--docs/users_guide/8.6.1-notes.rst5
-rw-r--r--testsuite/tests/typecheck/should_compile/T13833.hs12
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
4 files changed, 21 insertions, 2 deletions
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index 84309db598..6d866f795d 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 147558e139..4bc01c904e 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 0000000000..266b00bd60
--- /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 8a7a7da8ce..beaea5dcd1 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