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,413
    • Issues 5,413
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 603
    • Merge requests 603
  • 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
  • #21443
Closed
Open
Issue created Apr 27, 2022 by Richard Eisenberg@raeDeveloper

GHC calls an unambiguous record update ambiguous

Inspired by https://github.com/haskell/error-messages/issues/57

Here is the example:

data R = MkR1 { foo :: Int }
       | MkR2 { bar :: Int }

data S = MkS { foo :: Int, bar :: Int }

blah x = x { foo = 5, bar = 6 }

GHC says

Scratch.hs:37:10: error:
    * Record update is ambiguous, and requires a type signature
    * In the expression: x {foo = 5, bar = 6}
      In an equation for `blah': blah x = x {foo = 5, bar = 6}
   |
37 | blah x = x { foo = 5, bar = 6 }
   |          ^^^^^^^^^^^^^^^^^^^^^^

But it's not ambiguous. GHC rightly rejects that record-update if I write blah :: R -> R as a type signature, because foo and bar are in different constructors. In the record-update ambiguity check, GHC should take constructor choice into account.

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