[commit: ghc] master: Fixes bug #11046 (5593573)
git at git.haskell.org
git at git.haskell.org
Mon Jan 30 19:02:55 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/559357384e300355b62edb3d60dcc3fadb942a50/ghc
>---------------------------------------------------------------
commit 559357384e300355b62edb3d60dcc3fadb942a50
Author: Iavor S. Diatchki <iavor.diatchki at gmail.com>
Date: Mon Jan 30 11:57:35 2017 -0500
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
>---------------------------------------------------------------
559357384e300355b62edb3d60dcc3fadb942a50
compiler/typecheck/TcSplice.hs | 3 ++-
docs/users_guide/8.2.1-notes.rst | 3 +++
testsuite/tests/th/T11046.hs | 10 ++++++++++
testsuite/tests/th/T11046_helper.hs | 9 +++++++++
testsuite/tests/th/all.T | 1 +
5 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
index 9942107..15c3aba 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 ae156cb..9a38299 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 0000000..3c07c77
--- /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 0000000..f7fa19c
--- /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 d378412..f05a634 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'])
More information about the ghc-commits
mailing list