diff options
author | Daishi Nakajima <nakaji.dayo@gmail.com> | 2017-10-25 15:51:01 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-10-25 16:44:03 -0400 |
commit | f7f270eb6ba616feda79d370336db7e66f9ab79c (patch) | |
tree | faaea23391b1304ad54ca22aacde434d79057d03 /docs/users_guide/using-warnings.rst | |
parent | df636682f3b8299268d189bfaf6de1d672c19a73 (diff) | |
download | haskell-f7f270eb6ba616feda79d370336db7e66f9ab79c.tar.gz |
Implement `-Wpartial-fields` warning (#7169)
Warning on declaring a partial record selector.
However, disable warn with field names that start with underscore.
Test Plan: Added 1 test case.
Reviewers: austin, bgamari, simonpj
Reviewed By: bgamari, simonpj
Subscribers: goldfire, simonpj, duog, rwbarton, thomie
GHC Trac Issues: #7169
Differential Revision: https://phabricator.haskell.org/D4083
Diffstat (limited to 'docs/users_guide/using-warnings.rst')
-rw-r--r-- | docs/users_guide/using-warnings.rst | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 65ffe99cea..216d7ee232 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -78,6 +78,7 @@ The following flags are simple ways to select standard "packages" of warnings: * :ghc-flag:`-Wmissing-home-modules` * :ghc-flag:`-Widentities` * :ghc-flag:`-Wredundant-constraints` + * :ghc-flag:`-Wpartial-fields` .. ghc-flag:: -Weverything :shortdesc: enable all warnings supported by GHC @@ -1464,7 +1465,23 @@ of ``-W(no-)*``. pick up modules, not listed neither in ``exposed-modules``, nor in ``other-modules``. +.. ghc-flag:: -Wpartial-fields + :shortdesc: warn when define partial record field. + :type: dynamic + :reverse: -Wno-partial-fields + :category: + + :since: 8.4 + + The option :ghc-flag:`-Wpartial-fields` warns about record field that could + fail when it is used as a function. The function ``f`` below will fail when + applied to Bar, so the compiler will emit a warning about this when + :ghc-flag:`-Wpartial-fields` is enabled. + + The warning is suppressed if the field name begins with an underscore. :: + + data Foo = Foo { f :: Int } | Bar + If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice. It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's sanity, not yours.) - |