Skip to content

GitLab

  • Menu
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 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • 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 Compiler
  • GHCGHC
  • Issues
  • #21360
Closed
Open
Created Apr 07, 2022 by Jakob Brünker@JakobBruenkerDeveloper

Gratuitous -Wincomplete-record-updates warning in do-notation

Summary

{-# OPTIONS_GHC -Wincomplete-record-updates #-}
data Foo = A {a :: Int} | B deriving Show

foo = A 4

-- wibble is safe - no warning
wibble = do
  case foo of
    bar@A{} -> Just bar{a = 9}
    _ -> fail ":("

-- using guards doesn't throw a warning
twomble | bar@A{} <- foo = Just bar{a = 9}
        | otherwise  = fail ":("

-- sworble has the same semantics as wibble and twomble - but we get a warning!
sworble = do
  bar@A{} <- Just foo
  Just bar{a = 9}

Output:

DoBug.hs:19:8: warning: [-Wincomplete-record-updates]
    Pattern match(es) are non-exhaustive
    In a record-update construct: Patterns of type `Foo' not matched: B
   |
19 |   Just bar{a = 9}
   |        ^^^^^^^^^^

Expected behavior

Don't warn

Environment

  • GHC version used: 9.3.20220401
Edited Apr 07, 2022 by Jakob Brünker
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking