Skip to content

A warning for partial field accesses

This was originally proposed by @rae, but I couldn't find a ticket for it:

data R = MkR1 { foo :: Int } | MkR2 Bool

bar :: R -> Int
bar r = foo r + 1

This generates no warnings but is dangerously partial.

The warning would be similar to -Wpartial-fields (#7169 (closed)) which warns about partial field definitions as in the first line of the example.

The warning proposed here would warn about the usage of such a partial field as in the last line of the example.

The warning could be called -Wincomplete-record-accesses in analogy to -Wincomplete-record-updates.

Initially the warning should not be included in -Wall – instead it should see some testing in practice before potentially being added to -Wall.

The linked thread on the original proposal already contains some discussion on the warning proposed here.

Edited by Simon Jakobi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information