Skip to content

Emit warning if bang is applied to unlifted types #20187

Tito Sacchi requested to merge tsakki/ghc:strictness-flag-behavior into master

According to ticket #20187 (closed), it would be useful to emit a warning when a strictness flag (!) is applied to an unlifted type in a type constructor definition. GHC will now emit a warning like this:

Test.hs:7:13: warning:
    • Strictness flag has no effect on unlifted type ‘Int#’
        on the first argument of ‘TestCon’
    • In the definition of data constructor ‘TestCon’
      In the data type declaration for ‘Test’
  |
7 | data Test = TestCon !Int#
  |             ^^^^^^^^^^^^^

The UNPACK pragma lacks '!' warning won't be emitted anymore for unlifted types -- an Ignoring unusable UNPACK pragma warning will be triggered instead (as UNPACK does nothing on unlifted types at the moment) but only if optimizations are enabled (see #20204 (note 372106)). I don't understand why one would want a warning to be conditionally emitted depending on the optimization level, even with -Wall. But that's another topic -- I left the relevant code untouched.

Merge request reports