summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIavor S. Diatchki <iavor.diatchki@gmail.com>2017-01-30 11:57:35 -0500
committerBen Gamari <ben@smart-cactus.org>2017-01-30 14:00:23 -0500
commit559357384e300355b62edb3d60dcc3fadb942a50 (patch)
tree506c8197833ccf8cd816ae3c368acdc6c1e816e1
parent91691117fc194c525f58ccd5b266dd1d10493e5a (diff)
downloadhaskell-559357384e300355b62edb3d60dcc3fadb942a50.tar.gz
Fixes bug #11046
For some time now, type-level operators such as '+' have been treated as type constructors, rahter than type variables. This pathc fixes TH's `lookupName` function to account for this behavior. Reviewers: bgamari, austin, goldfire, RyanGlScott Reviewed By: RyanGlScott Subscribers: Phyx, thomie Differential Revision: https://phabricator.haskell.org/D3025 GHC Trac Issues: #11046
-rw-r--r--compiler/typecheck/TcSplice.hs3
-rw-r--r--docs/users_guide/8.2.1-notes.rst3
-rw-r--r--testsuite/tests/th/T11046.hs10
-rw-r--r--testsuite/tests/th/T11046_helper.hs9
-rw-r--r--testsuite/tests/th/all.T1
5 files changed, 25 insertions, 1 deletions
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
index 9942107c45..15c3aba063 100644
--- a/compiler/typecheck/TcSplice.hs
+++ b/compiler/typecheck/TcSplice.hs
@@ -1195,7 +1195,8 @@ lookupName is_type_name s
occ :: OccName
occ | is_type_name
- = if isLexCon occ_fs then mkTcOccFS occ_fs
+ = if isLexVarSym occ_fs || isLexCon occ_fs
+ then mkTcOccFS occ_fs
else mkTyVarOccFS occ_fs
| otherwise
= if isLexCon occ_fs then mkDataOccFS occ_fs
diff --git a/docs/users_guide/8.2.1-notes.rst b/docs/users_guide/8.2.1-notes.rst
index ae156cb110..9a38299739 100644
--- a/docs/users_guide/8.2.1-notes.rst
+++ b/docs/users_guide/8.2.1-notes.rst
@@ -193,6 +193,9 @@ Template Haskell
type variables ``a`` and ``k`` as implicitly quantified.
(:ghc-ticket:`13018` and :ghc-ticket:`13123`)
+- Looking up type constructors with symbol names (e.g., ``+``) now works
+ as expected (:ghc-ticket:`11046`)
+
Runtime system
~~~~~~~~~~~~~~
diff --git a/testsuite/tests/th/T11046.hs b/testsuite/tests/th/T11046.hs
new file mode 100644
index 0000000000..3c07c779f6
--- /dev/null
+++ b/testsuite/tests/th/T11046.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T11046 where
+
+import T11046_helper
+import GHC.TypeLits
+import Control.Monad(unless)
+
+$(check "GHC.TypeLits.*")
+$(check "GHC.TypeLits.+")
+$(check "GHC.TypeLits.Nat")
diff --git a/testsuite/tests/th/T11046_helper.hs b/testsuite/tests/th/T11046_helper.hs
new file mode 100644
index 0000000000..f7fa19cb51
--- /dev/null
+++ b/testsuite/tests/th/T11046_helper.hs
@@ -0,0 +1,9 @@
+{-# Language TemplateHaskell #-}
+module T11046_helper where
+import Language.Haskell.TH
+
+check :: String -> Q [Dec]
+check x = do mb <- lookupTypeName x
+ case mb of
+ Nothing -> fail "Bug #11046 is still present."
+ Just _ -> return []
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index d378412f94..f05a634301 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -370,3 +370,4 @@ test('T12993', normal, multimod_compile, ['T12993.hs', '-v0'])
test('T13018', normal, compile, ['-v0'])
test('T13123', normal, compile, ['-v0'])
test('T13098', normal, compile, ['-v0'])
+test('T11046', normal, multimod_compile, ['T11046','-v0'])