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
  • #21946
Closed
Open
Issue created Aug 01, 2022 by sheaf@sheafMaintainer

Type-directed disambiguation doesn't work for record updates using pattern synonyms; poor error message

{-# LANGUAGE DuplicateRecordFields, PatternSynonyms #-}

module T21946 where

pattern R1 :: Int -> Int
pattern R1 { fld } = fld

pattern R2 :: Bool -> Bool
pattern R2 { fld } = fld

f r = (r :: Int) { fld = undefined }

This fails with the error message:

    * `fld' is not a (visible) field of type `Int'
    * In the expression: (r :: Int) {fld = undefined}
      In an equation for `f': f r = (r :: Int) {fld = undefined}
   |
   | f r = (r :: Int) { fld = undefined }
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If one removes the definition of R2 then it works.

This is because the logic in GHC.Tc.Gen.Expr.identifyParent only deals with the TyCon parent case, and not the PatSyn parent case. But this type-directed disambiguation is scheduled to be removed in the future anyway.

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