-Wpartial-fields triggers even with -XNoFieldSelectors on
Summary
I'm a bit confused with the situation around -XNoFieldSelectors
and -Wpartial-fields
; I have two issues:
- why does
-Wpartial-fields
trigger on the declaration site; arguably it should only trigger if it is really used as a partial function; the warning makes it even worse where's the "Use" of partial field selector; shouldn't it be "Declaration"? - why does it even trigger if I don't even emit any field selectors
I would guess the former is just a wrinkle but the latter I think is really an issue, what do you think?
Steps to reproduce
{-# LANGUAGE NoFieldSelectors #-}
{-# OPTIONS_GHC -Wpartial-fields #-}
module Weird where
data A = B | C {foo :: Int}
output
GHCi, version 9.11.20240410: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /nix/store/7j77xbr06hsd4fzyc0iv2aclna57nknp-hm_ghciconf
[1 of 1] Compiling Weird ( Weird.hs, interpreted )
Weird.hs:6:17: warning: [GHC-82712] [-Wpartial-fields]
Use of partial record field selector: ‘foo’
|
6 | data A = B | C {foo :: Int}
| ^^^
Ok, one module loaded.
(0.02 secs,)
Expected behavior
- if
FieldSelectors
is on and-Wpartial-fields
is on, then we should see the warning only on partial uses of the record selector or at least have a warning message that says "Declaration of partial [..]" instead of "Use of partial [..]" - if
NoFieldSelectors
is on and-Wpartial-fields
is on, then we should not emit the warning
Environment
- GHC version used: GHC 9.4.8 / GHC 9.11
Optional:
- Operating System: NixOS
- System Architecture: x86_64-linux