Skip to content

PmCheck: Forcing a strict field can't lead to divergence

Consider the following test, inspired by !3289 (comment 280726):

{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
{-# LANGUAGE BangPatterns #-}
module Lib where

data T = MkT !Int

f :: T -> ()
f (MkT  _) | False = () -- inaccessible
f (MkT !_) | False = () -- redundant, not only inaccessible!
f _                = ()

Currently, GHC reports that the second clause of f is inaccessible, which is too conservative. The bang doesn't actually force anything, hence the whole clause is redundant.

CC @nineonine

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