summaryrefslogtreecommitdiff
path: root/testsuite/tests/dependent
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2018-12-03 07:03:52 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2018-12-03 07:03:52 -0500
commit2e6cc3d08f8439a2c0b6426e839d80072dbcda2c (patch)
tree55116f80290bc8e12e68d917265ae03003775921 /testsuite/tests/dependent
parent75a8349b2a7d0142d3d687837caf5a95bbb4368d (diff)
downloadhaskell-2e6cc3d08f8439a2c0b6426e839d80072dbcda2c.tar.gz
Fix #15954 by rejigging check_type's order
Summary: Previously, `check_type` (which catches illegal uses of unsaturated type synonyms without enabling `LiberalTypeSynonyms`, among other things) always checks for uses of polytypes before anything else. There is a problem with this plan, however: checking for polytypes requires decomposing `forall`s and other invisible arguments, an action which itself expands type synonyms! Therefore, if we have something like: ```lang=haskell type A a = Int type B (a :: Type -> Type) = forall x. x -> x type C = B A ``` Then when checking `B A`, `A` will get expanded to `forall x. x -> x` before `check_type` has an opportunity to realize that `A` is an unsaturated type synonym! This is the root cause of #15954. This patch fixes the issue by moving the case of `check_type` that detects polytypes to be //after// the case that checks for `TyConApp`s. That way, the `TyConApp` case will properly flag things like the unsaturated use of `A` in the example above before we ever attempt to check for polytypes. Test Plan: make test TEST=T15954 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15954 Differential Revision: https://phabricator.haskell.org/D5402
Diffstat (limited to 'testsuite/tests/dependent')
-rw-r--r--testsuite/tests/dependent/should_fail/T15859.hs1
-rw-r--r--testsuite/tests/dependent/should_fail/T15859.stderr2
2 files changed, 2 insertions, 1 deletions
diff --git a/testsuite/tests/dependent/should_fail/T15859.hs b/testsuite/tests/dependent/should_fail/T15859.hs
index e8ffdf4ae2..e7adc5fc98 100644
--- a/testsuite/tests/dependent/should_fail/T15859.hs
+++ b/testsuite/tests/dependent/should_fail/T15859.hs
@@ -1,6 +1,7 @@
{-# Language PolyKinds #-}
{-# Language TypeApplications #-}
{-# Language ImpredicativeTypes #-}
+{-# Language LiberalTypeSynonyms #-}
module T15859 where
diff --git a/testsuite/tests/dependent/should_fail/T15859.stderr b/testsuite/tests/dependent/should_fail/T15859.stderr
index e4794048b7..c4dc1ef086 100644
--- a/testsuite/tests/dependent/should_fail/T15859.stderr
+++ b/testsuite/tests/dependent/should_fail/T15859.stderr
@@ -1,5 +1,5 @@
-T15859.hs:13:5: error:
+T15859.hs:14:5: error:
• Cannot apply expression of type ‘forall k -> k -> *’
to a visible type argument ‘Int’
• In the expression: (undefined :: KindOf A) @Int