Skip to content

Commit

Permalink
Add documentation for GHC-83475 (Unused record wildcard)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitanie authored and slotThe committed Oct 11, 2024
1 parent 6b513c8 commit 96f86a0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions message-index/messages/GHC-83475/example1/after/Example1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-}
{-# LANGUAGE RecordWildCards #-}
module Example1 where

data Foo = Foo { x :: Int, y :: Int, name :: String }

f :: Foo -> String
f Foo{} = "Hello"
8 changes: 8 additions & 0 deletions message-index/messages/GHC-83475/example1/before/Example1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-}
{-# LANGUAGE RecordWildCards #-}
module Example1 where

data Foo = Foo { x :: Int, y :: Int, name :: String }

f :: Foo -> String
f Foo{..} = "Hello"
16 changes: 16 additions & 0 deletions message-index/messages/GHC-83475/example1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Pattern contains unused record wildcard
---

None of the fields bound by `Foo{..}` are used in `f`, so the pattern may be safely removed.

## Warning

```
GHC-83475/example1/before/Example1.hs:7:7: warning: [-Wunused-record-wildcards]
No variables bound in the record wildcard match are used
Possible fix: omit the ‘..’
|
7 | f Foo{..} = "Hello"
| ^^
```
9 changes: 9 additions & 0 deletions message-index/messages/GHC-83475/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Unused Record Wildcard
summary: Pattern contains record wildcard that is not used
severity: warning
flag: -Wunused-record-wildcards
introduced: 9.6.1
---

If `RecordWildCards` is enabled we can automatically bind fields of a record by using patterns like `MyRecord{..}`. Not using any of the record fields that were bound using the record wildcard syntax will result in a warning.

0 comments on commit 96f86a0

Please sign in to comment.