[Git][ghc/ghc][wip/T24049] users-guide: Fix discussion of -Wpartial-fields

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Oct 3 14:57:32 UTC 2023



Ben Gamari pushed to branch wip/T24049 at Glasgow Haskell Compiler / GHC


Commits:
03135171 by Ben Gamari at 2023-10-03T10:57:21-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,21 @@ 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`
+    ``f`` that is defined in some, but not all, the contructors of a
+    data type, because ``f``\ 's record selector function may fail.  For
+    example, 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.
+    :ghc-flag:`-Wpartial-fields` is enabled. ::
+
+        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/03135171c9902be077d2750edb71a9e3a7e65435

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03135171c9902be077d2750edb71a9e3a7e65435
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/20231003/93ae3d15/attachment-0001.html>


More information about the ghc-commits mailing list