[GHC] #12503: Template Haskell regression: GHC erroneously thinks a type variable is also a kind
GHC
ghc-devs at haskell.org
Wed Jan 25 04:51:34 UTC 2017
#12503: Template Haskell regression: GHC erroneously thinks a type variable is also
a kind
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: goldfire
Type: bug | Status: new
Priority: high | Milestone: 8.2.1
Component: Template Haskell | Version: 8.0.1
Resolution: | Keywords: TypeInType
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
I did some cursory debugging of this tonight. Here are my findings
1. This bug was definitely introduced in
6746549772c5cc0ac66c0fce562f297f4d4b80a2. (Add kind equalities to GHC.)
Not the most surprising turn of events, I know, but still nice to have
confirmed.
2. The lines of code that actually produce this error are in
[http://git.haskell.org/ghc.git/blob/65cc7620517abec9b3e0d9bfe644accd5f649fe5:/compiler/rename/RnTypes.hs#l1690
RnTypes]:
{{{#!hs
extract_tv :: TypeOrKind -> Located RdrName -> FreeKiTyVars -> RnM
FreeKiTyVars
extract_tv t_or_k ltv@(L _ tv) acc
| isRdrTyVar tv = case acc of
FKTV kvs k_set tvs t_set all
| isTypeLevel t_or_k
-> do { when (occ `elemOccSet` k_set) $
mixedVarsErr ltv
; return (FKTV kvs k_set (ltv : tvs) (t_set
`extendOccSet` occ)
(ltv : all)) }
| otherwise
-> do { when (occ `elemOccSet` t_set) $
mixedVarsErr ltv
; return (FKTV (ltv : kvs) (k_set `extendOccSet` occ) tvs
t_set
(ltv : all)) }
| otherwise = return acc
where
occ = rdrNameOcc tv
}}}
where `mixedVarsErr ltv` actually throws the "used as both a kind and a
type" error.
I decided to do some `pprTrace` debugging in this neighborhood, and I
discovered that when you run the program above, the error gets thrown in
the `isTypeLevel t_or_k` case. Here's some values at the moment of the
error:
{{{
RGS typelevel
kvs : [k_a1ly]
k_set : [vESeYM :-> k]
tvs : []
t_set : []
all : [k_a1ly]
tv : k_a1lx
rdrNameOcc tv (occ) : k
}}}
What does this mean? I don't yet—I'll need to do some more digging.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12503#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list