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,245
    • Issues 5,245
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 568
    • Merge requests 568
  • 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
  • #21898
Closed
Open
Issue created Jul 21, 2022 by sheaf@sheafMaintainer

Problems disambiguating a record update with pattern synonyms

The parent of a pattern synonym record field is the pattern synonym itself, which I think makes sense (a pattern synonym behaves much like a data constructor). However, it seems that the following variant on #21443 causes GHC to trip over:

{-# LANGUAGE DuplicateRecordFields, PatternSynonyms #-}

pattern P :: Int -> Int -> (Int, Int)
pattern P { proj_x, proj_y } = (proj_x, proj_y)

pattern Q1 :: Int -> Int
pattern Q1 { proj_x } = proj_x

pattern Q2 :: Int -> Int
pattern Q2 { proj_y } = proj_y

blah :: (Int, Int) -> (Int, Int)
blah p = p { proj_x = 0, proj_y = 1 }
error:
    * GHC internal error: `T21443b.$sel:proj_x:P' is not in scope during type checking, but it passed the renamer
      tcl_env of environment: [auv :-> Identifier[p::(Int,
                                                      Int), NotLetBound],
                               rgF :-> Identifier[blah::(Int, Int)
                                                        -> (Int, Int), TopLevelLet {} True]]
    * In the expression: p {proj_x = 0, proj_y = 1}
      In an equation for `blah': blah p = p {proj_x = 0, proj_y = 1}
   |
   | blah p = p { proj_x = 0, proj_y = 1 }
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking