[Git][ghc/ghc][master] This MR is an implementation of the proposal #516.
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Jul 26 21:23:37 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
503fd647 by Bartłomiej Cieślar at 2023-07-26T17:23:10-04:00
This MR is an implementation of the proposal #516.
It adds a warning -Wincomplete-record-selectors for usages of a record
field access function (either a record selector or getField @"rec"),
while trying to silence the warning whenever it can be sure that a constructor
without the record field would not be invoked (which would otherwise cause
the program to fail). For example:
data T = T1 | T2 {x :: Bool}
f a = x a -- this would throw an error
g T1 = True
g a = x a -- this would not throw an error
h :: HasField "x" r Bool => r -> Bool
h = getField @"x"
j :: T -> Bool
j = h -- this would throw an error because of the `HasField`
-- constraint being solved
See the tests DsIncompleteRecSel* and TcIncompleteRecSel for more examples of the warning.
See Note [Detecting incomplete record selectors] in GHC.HsToCore.Expr for implementation details
- - - - -
30 changed files:
- compiler/GHC/Core/ConLike.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Errors/Ppr.hs
- compiler/GHC/HsToCore/Errors/Types.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Pmc/Check.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/HsToCore/Pmc/Utils.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Types/Error.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/TyThing.hs
- docs/users_guide/9.10.1-notes.rst
- docs/users_guide/9.8.1-notes.rst
- docs/users_guide/using-warnings.rst
- testsuite/tests/plugins/all.T
- + testsuite/tests/pmcheck/should_compile/DsIncompleteRecSel1.hs
- + testsuite/tests/pmcheck/should_compile/DsIncompleteRecSel1.stderr
- + testsuite/tests/pmcheck/should_compile/DsIncompleteRecSel2.hs
- + testsuite/tests/pmcheck/should_compile/DsIncompleteRecSel2.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/503fd6478086144a00e424d02cc21773a8e0ee24
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/503fd6478086144a00e424d02cc21773a8e0ee24
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/20230726/8b3a9cc7/attachment.html>
More information about the ghc-commits
mailing list