diff --git a/message-index/messages/GHC-83475/example1/after/Example1.hs b/message-index/messages/GHC-83475/example1/after/Example1.hs new file mode 100644 index 00000000..d8bfada2 --- /dev/null +++ b/message-index/messages/GHC-83475/example1/after/Example1.hs @@ -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" diff --git a/message-index/messages/GHC-83475/example1/before/Example1.hs b/message-index/messages/GHC-83475/example1/before/Example1.hs new file mode 100644 index 00000000..3364ee11 --- /dev/null +++ b/message-index/messages/GHC-83475/example1/before/Example1.hs @@ -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" diff --git a/message-index/messages/GHC-83475/example1/index.md b/message-index/messages/GHC-83475/example1/index.md new file mode 100644 index 00000000..db8f24bc --- /dev/null +++ b/message-index/messages/GHC-83475/example1/index.md @@ -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" + | ^^ +``` diff --git a/message-index/messages/GHC-83475/index.md b/message-index/messages/GHC-83475/index.md new file mode 100644 index 00000000..e91cb87a --- /dev/null +++ b/message-index/messages/GHC-83475/index.md @@ -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.