[GHC] #14848: -XDuplicateRecordFields breaks record expression splices

GHC ghc-devs at haskell.org
Sat Feb 24 17:16:58 UTC 2018


#14848: -XDuplicateRecordFields breaks record expression splices
-------------------------------------+-------------------------------------
           Reporter:  dailectic      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
           Keywords:                 |  Operating System:  Linux
       Architecture:  x86_64         |   Type of failure:  GHC rejects
  (amd64)                            |  valid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 {{{
 {-# language TemplateHaskell #-}
 {-# language DuplicateRecordFields #-}
 module Lib where
 import Language.Haskell.TH
 import Language.Haskell.TH.Syntax

 data A = A {x :: Int, y :: String}
 a = A 3 "test"
 test = $([e|case a of A {x = b} -> b|])
 }}}

 Without `DuplicateRecordFields` it compiles correctly so `test = 3` but
 with `DuplicateRecordFields` enabled it gives:

 {{{
      • Illegal variable name: ‘$sel:x:A’
       When splicing a TH expression:
         case Lib.a of
     (Lib.A {Lib.$sel:x:A = b_0}) -> b_0
     • In the untyped splice: $([| case a of { A {x = b} -> b } |])
 }}}

 Additionally, there doesn't seem to be a workaround for munging the name
 manually, since the `$sel:x:A` name is the one actually in scope, there is
 no `A.x` like there would be normally, even when the label is not a
 duplicate.

 Is there a way to get around this? Ex: by changing the binding name
 somehow manually?

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


More information about the ghc-tickets mailing list