[GHC] #11809: Template Haskell record splices are not renamer-resolved correctly.

GHC ghc-devs at haskell.org
Thu Apr 7 11:44:54 UTC 2016


#11809: Template Haskell record splices are not renamer-resolved correctly.
-------------------------------------+-------------------------------------
           Reporter:  bollmann       |             Owner:  bollmann
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.0.1
  Haskell                            |
           Keywords:  Template       |  Operating System:  Unknown/Multiple
  Haskell Renamer Records            |
       Architecture:                 |   Type of failure:  GHC rejects
  Unknown/Multiple                   |  valid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 While working on ticket #8761, I noticed that splicing in record selectors
 with Template Haskell seems to cause renamer issues in GHC HEAD.

 Consider the following TH splice:

 {{{#!hs

 {- Test splicing in a data type with records -}
 [d|
  data D a = MkD { unD :: a }

  someD = MkD "Hello"
  getD  = unD someD      -- unD should resolve to the record selector
 above!
  |]

 getD' = unD someD       -- dito here outside of the splice!
 }}}

 While GHC 7.10.3 accepts this splice and renames it correctly, GHC HEAD
 fails with the following error message (with `-ddump-splices` enabled):

 {{{
 [1 of 1] Compiling Error            ( Error.hs, Error.o )
 Error.hs:(6,1)-(11,3): Splicing declarations
     [d| someD_apF = MkD_apD "Hello"
         getD_apG = unD someD_apF

         data D_apC a_apH = MkD_apD {unD :: a_apH} |]
   ======>
     data D_a4SA a_a4SD = MkD_a4SB {unD_a4SC :: a_a4SD}
     someD_a4Sy = MkD_a4SB "Hello"
     getD_a4Sz = unD_a4SC someD_a4Sy

 Error.hs:6:1: error:
     The exact Name ‘unD_a4SC’ is not in scope
       Probable cause: you used a unique Template Haskell name (NameU),
       perhaps via newName, but did not bind it
       If that's it, then -ddump-splices might be useful
 }}}

 I'm not sure as to what introduced this bug, but investigating it I found
 that the notes

 - `NOTE [Binders in Template Haskell] in Convert.hs`, and
 - `NOTE [Looking up Exact RdrNames] in RnEnv.hs`

 are not respected by function `newRecordSelector` in `rename/RnNames.hs`.
 I've fixed this function accordingly in Phab:D1940 for #8761, but since
 that patch is not going to be part of 8.0.1, Richard suggested to fix it
 separately in this ticket.

 I'm submitting a patch in due course.

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


More information about the ghc-tickets mailing list