Skip to content

hpc complains that record field referencing an existential is never executed

Summary

{-# LANGUAGE ExistentialQuantification #-}
module Main where

data Any = forall a. Any { any :: a }

main :: IO ()
main = do
  let x = Any 'c'
  case x of
    Any _ -> pure ()

image

Steps to reproduce

ghc -fhpc Test.hs && ./Test && hpc report Test

Expected behavior

any is not marked up as never executed, as there is no way to call it

Environment

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