DuplicateRecordFields doesn't work with TH-generated records
There are a bunch of tickets about the fact that TH doesn't really work with
DuplicateRecordFields, but I couldn't find one for this specific issue.
Generating multiple records using TH whose fields share textual names does not work. The generated code passes the typechecker but generates linker errors, e.g.
/run/user/1000/ghc1993779_0/ghc_11.s:79586:0: error: Error: symbol `lspzmtypeszm1zi5zi0zi0zminplace_LanguageziLSPziMetaModelziGenerated_textDocument_info' is already defined | 79586 | lspzmtypeszm1zi5zi0zi0zminplace_LanguageziLSPziMetaModelziGenerated_textDocument_info:
I guess that the generated fields are not getting mangled as described in #11103 (closed).
Steps to reproduce
Generate records which have duplicated fields using e.g.
newName "fieldA" twice, enable
DuplicateRecordFields. Observe linker errors.
e.g. (not compiled)
noBang = Bang NoSourceUnpackedness NoSourceStrictness mkRecords = do tn1 <- newName "R1" cn1 <- newName "C1" fn1 <- newName "f" let r1 = DataD  tn1  Nothing [RecC cn1 [(fn1, noBang, ConT ''Integer)]]  tn2 <- newName "R2" cn2 <- newName "C2" fn2 <- newName "f" let r2 = DataD  tn2  Nothing [RecC cn2 [(fn2, noBang, ConT ''Integer)]]  $mkRecords
Allow the duplicated record fields
- GHC version used: Observed on both 8.10.7 and 9.0.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information