-XDuplicateRecordFields breaks record expression splices
{-# 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?
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |