[Git][ghc/ghc][master] users-guide: Fix discussion of -Wpartial-fields
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Oct 4 09:48:47 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
e037f459 by Ben Gamari at 2023-10-04T05:45:35-04:00
users-guide: Fix discussion of -Wpartial-fields
* fix a few typos
* add a new example showing when the warning fires
* clarify the existing example
* point out -Wincomplete-record-selects
Fixes #24049.
- - - - -
1 changed file:
- docs/users_guide/using-warnings.rst
Changes:
=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -2157,16 +2157,19 @@ of ``-W(no-)*``.
:since: 8.4
The option :ghc-flag:`-Wpartial-fields` warns about a record field
- `f` that is defined in some, but not all, the contructors of a
- data type, because `f`'s record selector function may fail. For
- exampe, the record selector function `f`, defined in the `Foo`
- constructor record below, will fail when applied to ``Bar``, so
- the compiler will emit a warning at its definition when
- :ghc-flag:`-Wpartial-fields` is enabled.
+ ``f`` that is defined in some, but not all, of the constructors of a
+ data type, as such selector functions are partial. For example, when
+ :ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at
+ the definition of ``Foo`` below: ::
+
+ data Foo = Foo { f :: Int } | Bar
The warning is suppressed if the field name begins with an underscore. ::
- data Foo = Foo { f :: Int } | Bar
+ data Foo = Foo { _f :: Int } | Bar
+
+ Another related warning is :ghc-flag:`-Wincomplete-record-selectors`,
+ which warns at use sites rather than definition sites.
.. ghc-flag:: -Wunused-packages
:shortdesc: warn when package is requested on command line, but not needed.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e037f45940a60027a6d95627c2ab1b2676acb9a4
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e037f45940a60027a6d95627c2ab1b2676acb9a4
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231004/d4adcf5e/attachment-0001.html>
More information about the ghc-commits
mailing list