diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-02-09 09:50:42 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-02-12 02:50:03 -0500 |
commit | 012257c15f584069500af2953ab70856f9a1470e (patch) | |
tree | e6822fee11572b3d04194da8c14b6e7f3794519d /testsuite | |
parent | 6399965d7f1636db6c777f597192467f93d800b1 (diff) | |
download | haskell-012257c15f584069500af2953ab70856f9a1470e.tar.gz |
Fix #16293 by cleaning up Proxy# infelicities
This bug fixes three problems related to `Proxy#`/`proxy#`:
1. Reifying it with TH claims that the `Proxy#` type constructor has
two arguments, but that ought to be one for consistency with
TH's treatment for other primitive type constructors like `(->)`.
This was fixed by just returning the number of
`tyConVisibleTyVars` instead of using `tyConArity` (which includes
invisible arguments).
2. The role of `Proxy#`'s visible argument was hard-coded as nominal.
Easily fixed by changing it to phantom.
3. The visibility of `proxy#`'s kind argument was specified, which
is different from the `Proxy` constructor (which treats it as
inferred). Some minor refactoring in `proxyHashId` fixed ths up.
Along the way, I had to introduce a `mkSpecForAllTy` function, so
I did some related Haddock cleanup in `Type`, where that function
lives.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/primops/should_compile/T16293a.hs | 19 | ||||
-rw-r--r-- | testsuite/tests/primops/should_compile/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/th/T16293b.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
4 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/primops/should_compile/T16293a.hs b/testsuite/tests/primops/should_compile/T16293a.hs new file mode 100644 index 0000000000..69368c70b5 --- /dev/null +++ b/testsuite/tests/primops/should_compile/T16293a.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +module T16293a where + +import Data.Coerce +import Data.Proxy +import GHC.Exts + +test1a :: () -> Proxy Int +test1a _ = Proxy @Int + +test1b :: () -> Proxy# Int +test1b _ = proxy# @Int + +test2a :: (() -> Proxy a) -> (() -> Proxy b) +test2a = coerce + +test2b :: (() -> Proxy# a) -> (() -> Proxy# b) +test2b = coerce diff --git a/testsuite/tests/primops/should_compile/all.T b/testsuite/tests/primops/should_compile/all.T index a934e4ca9e..aa7339c445 100644 --- a/testsuite/tests/primops/should_compile/all.T +++ b/testsuite/tests/primops/should_compile/all.T @@ -1 +1,2 @@ test('T6135_should_compile', normal, compile, ['']) +test('T16293a', normal, compile, ['']) diff --git a/testsuite/tests/th/T16293b.hs b/testsuite/tests/th/T16293b.hs new file mode 100644 index 0000000000..85affa5204 --- /dev/null +++ b/testsuite/tests/th/T16293b.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TemplateHaskell #-} +module T16293b where + +import Control.Monad +import GHC.Exts +import Language.Haskell.TH + +f :: () +f = $(do PrimTyConI _ arity _ <- reify ''Proxy# + unless (arity == 1) $ + fail $ "Unexpected arity for Proxy#: " ++ show arity + [| () |]) diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index a92cef42f1..2aaa48c127 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -464,3 +464,4 @@ test('T15471', normal, multimod_compile, ['T15471.hs', '-v0']) test('T16180', normal, compile_and_run, ['-package ghc']) test('T16183', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T16195', normal, multimod_compile, ['T16195.hs', '-v0']) +test('T16293b', normal, compile, ['']) |