diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2017-06-23 11:40:50 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-06-23 11:40:51 -0400 |
commit | 9077120918b78f5152bf3596fe6df07b91cead79 (patch) | |
tree | 30e4532f9a714d88ae9242dd1fb2f5c3a3b58063 /testsuite | |
parent | 3c4537ea1c940966eddcb9cb418bf8e39b8f0f1c (diff) | |
download | haskell-9077120918b78f5152bf3596fe6df07b91cead79.tar.gz |
Use actual universal tvs in check for naughty record selectors
The naughty record selector check means to limit selectors which would
lead to existential tyvars escaping their scope. With record pattern
synonyms, there are situations where universal tyvars don't appear in
the result type, for example:
```
pattern ReadP :: Read a => a -> String
pattern ReadP{readp} <- (read -> readp)
```
This is a similar issue to #11224 where we assumed that we can decide
which variables are universal and which are existential by the syntactic
check of seeing which appear in the result type. The fix is to use
`univ_tvs` from `conLikeFullSig` rather than the previous approximation.
But we must also remember to apply `EqSpec`s so we use the free
variables from `inst_tys` which is precisely `univ_tvs` with `EqSpecs`
applied.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3649
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/patsyn/should_run/records-run.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_run/records-run.stdout | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_run/records-run.hs b/testsuite/tests/patsyn/should_run/records-run.hs index 19a6bb2793..1719045ffd 100644 --- a/testsuite/tests/patsyn/should_run/records-run.hs +++ b/testsuite/tests/patsyn/should_run/records-run.hs @@ -1,4 +1,6 @@ {-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ViewPatterns #-} module Main where @@ -6,9 +8,14 @@ pattern Bi{a, b} = (a, b) foo = ("a","b") +pattern ReadP :: Read a => a -> String +pattern ReadP {readp} <- (read -> readp) + main = do print foo print (a foo) print (b foo) print (foo {a = "c"}) print (foo {a = "fst", b = "snd"}) + + print (readp @Int "5") diff --git a/testsuite/tests/patsyn/should_run/records-run.stdout b/testsuite/tests/patsyn/should_run/records-run.stdout index a0878c75b3..e76be9cff7 100644 --- a/testsuite/tests/patsyn/should_run/records-run.stdout +++ b/testsuite/tests/patsyn/should_run/records-run.stdout @@ -3,3 +3,4 @@ "b" ("c","b") ("fst","snd") +5 |