[GHC] #14918: GHC 8.4.1 regression: derived Read instances with field names containing # no longer parse

GHC ghc-devs at haskell.org
Wed Mar 14 01:56:14 UTC 2018


#14918: GHC 8.4.1 regression: derived Read instances with field names containing #
no longer parse
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  Compiler          |              Version:  8.4.1
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #5041, #14364     |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * related:  #14364 => #5041, #14364


Comment:

 Ah, I know what is happening here. #5041 is quite relevant, as is
 [http://git.haskell.org/ghc.git/blob/152055a19cf368439c8450040b68142f8e7d0346:/compiler/typecheck/TcGenDeriv.hs#l1057
 this comment] from the GHC source:

 {{{#!hs
     -- For constructors and field labels ending in '#', we hackily
     -- let the lexer generate two tokens, and look for both in sequence
     -- Thus [Ident "I"; Symbol "#"].  See Trac #5041
 }}}

 Now let's look at
 [http://git.haskell.org/ghc.git/blob/152055a19cf368439c8450040b68142f8e7d0346:/libraries/base/GHC/Read.hs#l370
 what readField does]:

 {{{#!hs
 readField :: String -> ReadPrec a -> ReadPrec a
 readField fieldName readVal = do
         expectP (L.Ident fieldName)
         expectP (L.Punc "=")
         readVal
 }}}

 Alas, it attempts to treat the field name as a single `Ident`. But if that
 field name contains a `#` (e.g., `runT#`, as in the original example),
 then this will fail.

 It looks like we'll need a variant of `readField` that takes hashes into
 account.

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


More information about the ghc-tickets mailing list