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

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Oct 3 16:44:17 UTC 2023



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


Commits:
76641510 by Ben Gamari at 2023-10-03T12:44:11-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/7664151082235936696afac9a2a4cc7cb9f3277f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7664151082235936696afac9a2a4cc7cb9f3277f
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/47caf021/attachment-0001.html>


More information about the ghc-commits mailing list