Skip to content

Spurious `-Wincomplete-record-selectors` warning with GHC 9.10.1

Summary

After upgrading from GHC 9.8.2 to 9.10.1, I started getting a warning in an unexpected place. I discovered the issue here: https://github.com/tfausak/imp/pull/24#issuecomment-2116480980.

Steps to reproduce

Compile this module:

{-# OPTIONS_GHC -Wincomplete-record-selectors #-}

import GHC.Hs

main = do
  let hsModule = undefined :: HsModule GhcPs
  let _ = hsmodImports $ hsModule -- warns
  let _ = hsmodImports hsModule -- does not warn
  pure ()

Expected behavior

I expected no warnings to be emitted.

Instead I get this warning:

GhcBug.hs:7:11: warning: [GHC-17335] [-Wincomplete-record-selectors]
    The application of the record field ‘hsmodImports’ may fail for the following constructors: XModule
  |
7 |   let _ = hsmodImports $ hsModule -- warns
  |           ^^^^^^^^^^^^

Environment

  • GHC version used: 9.10.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information