Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,410
    • Issues 5,410
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 604
    • Merge requests 604
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #21720
Closed
Open
Issue created Jun 11, 2022 by Michael Peyton Jones@michaelpjReporter

DuplicateRecordFields doesn't work with TH-generated records

Summary

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

Expected behavior

Allow the duplicated record fields

Environment

  • 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
Assignee
Assign to
Time tracking