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
  • #22160
Closed
Open
Issue created Sep 09, 2022 by Adam Gundry@adamgundryDeveloper

DisambiguateRecordFields, not DuplicateRecordFields, should control name resolution for record updates

At the moment, the DuplicateRecordFields extension changes name resolution for record updates so that it is sufficient for one type (or, following #21443 (closed), one constructor) to have all the fields being updated. I claim that this behaviour should be enabled by the DisambiguateRecordFields extension instead. This would mean DisambiguateRecordFields controls all the special name lookup rules for use sites, while DuplicateRecordFields merely allows the definition of the same field name multiple times in the same module. (I'm assuming a post-#19461 world where the type-directed resolution is gone.)

Since DuplicateRecordFields implies DisambiguateRecordFields, this change should almost always accept more programs.

Concretely, the following program is rejected with ambiguity errors on the record update, but I think it should be accepted:

module MS where
  data S = MkS { x :: Int }

module MT where
  data T = MkT { x :: Int, y :: Int }

module MU where
  data U = MkU { y :: Int }

{-# LANGUAGE DisambiguateRecordFields #-} -- using DuplicateRecordFields here instead would work already
module N where
  import MS
  import MT
  import MU

  eg r = r { x = 1, y = 1 }

@sheaf you may have an opinion as this relates to !8686 (merged)?

Edited Sep 09, 2022 by Adam Gundry
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking