Commit 55935738 authored by Iavor S. Diatchki's avatar Iavor S. Diatchki Committed by Ben Gamari

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
parent 91691117
......@@ -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
......
......@@ -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
~~~~~~~~~~~~~~
......
{-# 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")
{-# 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 []
......@@ -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'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment