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
  • #23062
Closed
Open
Issue created Mar 02, 2023 by sheaf@sheafMaintainer

Record fields pushing each other out of scope in GHCi is unintuitive

If we try the following in GHCi:

:seti -XDuplicateRecordFields
data A = MkA { foo :: Int, bar :: Int }
data B = MkB { foo :: Int }
f r = r { foo = 3, bar = 4 }

we get an error:

<interactive>:4:7: error:
    * No constructor has all these fields: `foo', `bar'
    * In the expression: r {foo = 3, bar = 4}
      In an equation for `f': f r = r {foo = 3, bar = 4}

This is because the definition data B = MkB { foo :: Int } has shadowed the record field foo of A, making it only available under the qualifier Ghci1. The following record update is accepted:

g r = r { Ghci1.foo = 3, bar = 4 }

I will fix in !8686 (merged).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking