[GHC] #10996: family is treated as keyword in types even without TypeFamilies enabled

GHC ghc-devs at haskell.org
Fri Oct 23 05:50:43 UTC 2015


#10996: family is treated as keyword in types even without TypeFamilies enabled
-------------------------------------+-------------------------------------
        Reporter:  oerjan            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  GHC rejects       |            Test Case:  type Test
  valid program                      |  family = family
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by oerjan):

 I note this quote in
 [https://raw.githubusercontent.com/ghc/ghc/master/compiler/parser/Lexer.x
 lexer.x]:

 > One might think that we wish to treat 'family' and 'role' as regular old
 > varids whenever -XTypeFamilies and -XRoleAnnotations are off,
 respectively.
 > But, there is no need to do so. These pseudo-keywords are not stolen
 syntax:
 > they are only used after the keyword 'type' at the top-level, where
 varids are
 > not allowed. Furthermore, checks further downstream (TcTyClsDecls)
 ensure that
 > type families and role annotations are never declared without their
 extensions
 > on. In fact, by unconditionally lexing these pseudo-keywords as special,
 we
 > can get better error messages.
 >
 > Also, note that these are included in the `varid` production in the
 parser --
 > a key detail to make all this work.

 So clearly it was ''intended'' that they not be stolen, but something got
 messed up, perhaps when declaring types with `TypeOperators` were allowed.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10996#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list