Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
6144 commits behind the upstream repository.
Bartłomiej Cieślar's avatar
Bartłomiej Cieślar authored
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
503fd647
History
Name Last commit Last update
..
T16104-plugin
T20803-plugin
annotation-plugin
defaulting-plugin
echo-plugin
hole-fit-plugin
hooks-plugin
plugin-recomp
rule-defining-plugin
shared-plugin
simple-plugin
FrontendPlugin.hs
HomePackagePlugin.hs
LinkerTicklingPlugin.hs
Makefile
MetaRemoveHelper.hs
PluginFilteredExport.hs
PluginRecompTest.hs
QuasiQuotation.hs
T10294.hs
T10294.stderr
T10294a.hs
T10420.hs
T10420.stdout
T10420a.hs
T11244.hs
T11244.stderr
T12567a.hs
T12567a.stderr
T12567b.hs
T14335.hs
T14335.stderr
T15858.script
T15858.stderr
T16104.hs
T16104.stdout
T16260.hs
T16260.stdout
T19926.hs
T19926.stderr
T20218.hs
T20218b.hs
T20218b.stderr
T20218b.stdout
T20417.stderr
T20803a.hs
T20803a.stderr
T20803b.hs
T20803b.stderr
all.T
frontend01.hs
frontend01.stdout
plugin-recomp-change-2.stderr
plugin-recomp-change-prof.stderr
plugin-recomp-change.stderr
plugin-recomp-flags.stderr
plugin-recomp-flags.stdout
plugin-recomp-impure.stderr
plugin-recomp-impure.stdout
plugin-recomp-pure.stderr
plugin-recomp-pure.stdout
plugin-recomp-test.hs
plugins-external.hs
plugins-external.stderr
plugins-external.stdout
plugins-ghci.hs
plugins-ghci.stdout
plugins-order-pragma.hs
plugins-order-pragma.stderr
plugins-order.hs
plugins-order.stderr
plugins01.hs
plugins01.stderr
plugins01.stdout
plugins02.hs
plugins02.stderr
plugins03.hs
plugins03.stderr
plugins04.hs
plugins04.stderr
plugins05.hs
plugins05.stdout
plugins06.hs
plugins07.hs
plugins07.stdout
plugins08.hs
plugins08.stderr
plugins08.stdout
plugins09.hs
plugins09.stdout
plugins10.hs
plugins10.stdout
plugins11.hs
plugins11.stdout
plugins12.hs
plugins13.hs
plugins14.hs
plugins15.hs
static-plugins-module.hs
static-plugins.hs