[Git][ghc/ghc][master] Correct -Wpartial-fields warning to say "Definition" rather than "Use"
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Jul 4 15:13:56 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
6c469bd2 by Adam Gundry at 2024-07-04T11:10:33-04:00
Correct -Wpartial-fields warning to say "Definition" rather than "Use"
Fixes #24710. The message and documentation for `-Wpartial-fields` were
misleading as (a) the warning occurs at definition sites rather than use
sites, and (b) the warning relates to the definition of a field independently
of the selector function (e.g. because record updates are also partial).
- - - - -
5 changed files:
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- docs/users_guide/using-warnings.rst
- testsuite/tests/overloadedrecflds/should_fail/DRFPartialFields.stderr
- testsuite/tests/typecheck/should_compile/T7169.stderr
Changes:
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -1501,8 +1501,9 @@ instance Diagnostic TcRnMessage where
text "You may define an abstract closed type family" $$
text "only in a .hs-boot file"
TcRnPartialFieldSelector fld -> mkSimpleDecorated $
- sep [text "Use of partial record field selector" <> colon,
- nest 2 $ quotes (ppr (occName fld))]
+ vcat [ sep [ text "Definition of partial record field" <> colon
+ , nest 2 $ quotes (ppr (occName fld)) ]
+ , text "Record selection and update using this field will be partial." ]
TcRnHasFieldResolvedIncomplete name -> mkSimpleDecorated $
text "The invocation of `getField` on the record field" <+> quotes (ppr name)
<+> text "may produce an error since it is not defined for all data constructors"
=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -3503,7 +3503,7 @@ data TcRnMessage where
-}
TcRnAbstractClosedTyFamDecl :: TcRnMessage
- {-| TcRnPartialFieldSelector is a warning indicating that a record selector
+ {-| TcRnPartialFieldSelector is a warning indicating that a record field
was not defined for all constructors of a data type.
Test cases:
=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -2154,7 +2154,7 @@ of ``-W(no-)*``.
The option :ghc-flag:`-Wpartial-fields` warns about a record field
``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
+ data type, as record selection and update will be partial. For example, when
:ghc-flag:`-Wpartial-fields` is enabled the compiler will emit a warning at
the definition of ``Foo`` below: ::
@@ -2164,8 +2164,9 @@ of ``-W(no-)*``.
data Foo = Foo { _f :: Int } | Bar
- Another related warning is :ghc-flag:`-Wincomplete-record-selectors`,
- which warns at use sites rather than definition sites.
+ Related warnings are :ghc-flag:`-Wincomplete-record-selectors` and
+ :ghc-flag:`-Wincomplete-record-updates`,
+ which warn at use sites rather than definition sites.
.. ghc-flag:: -Wunused-packages
:shortdesc: warn when package is requested on command line, but not needed.
=====================================
testsuite/tests/overloadedrecflds/should_fail/DRFPartialFields.stderr
=====================================
@@ -1,3 +1,4 @@
DRFPartialFields.hs:4:17: error: [GHC-82712] [-Wpartial-fields, Werror=partial-fields]
- Use of partial record field selector: ‘foo’
+ Definition of partial record field: ‘foo’
+ Record selection and update using this field will be partial.
=====================================
testsuite/tests/typecheck/should_compile/T7169.stderr
=====================================
@@ -1,2 +1,3 @@
T7169.hs:11:5: warning: [GHC-82712] [-Wpartial-fields]
- Use of partial record field selector: ‘m2’
+ Definition of partial record field: ‘m2’
+ Record selection and update using this field will be partial.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c469bd2f5632ca59b691d07956ee61c717efbc0
--
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c469bd2f5632ca59b691d07956ee61c717efbc0
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/20240704/b3179615/attachment-0001.html>
More information about the ghc-commits
mailing list