Opened 16 months ago

Last modified 16 months ago

#15504 new bug

-XStrict doesn't prevent warnings from -Wunbanged-strict-patterns

Reported by: ChaiTRex Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.4.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I'm using:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.4.3

I was under the impression that -XStrict automatically included outermost bang patterns, but either that isn't always the case or -Wunbanged-strict-patterns doesn't know that -XStrict did its job correctly:

{-# OPTIONS_GHC -Wunbanged-strict-patterns #-}
{-# LANGUAGE BangPatterns, MagicHash, Strict, UnboxedTuples #-}

module Example where

import GHC.Exts  (Int(I#), quotRemInt#)

lastDigit :: Int -> Int
lastDigit (I# x) = let (# q, r #) = quotRemInt# x 10#
                   in  I# r

compiles with a warning:

[1 of 1] Compiling Example          ( Example.hs, Example.o )

Example.hs:9:24: warning: [-Wunbanged-strict-patterns]
    Pattern bindings containing unlifted types should use
    an outermost bang pattern:
      (# q, r #) = quotRemInt# x 10#
  |
9 | lastDigit (I# x) = let (# q, r #) = quotRemInt# x 10#
  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Change History (1)

comment:1 Changed 16 months ago by simonpj

-Wunbanged-strict-patterns works on the code the user wrote, not the code after -XStrict has notionally munged it. You could argue either way, I suppose, but my suggestion would just be to put the bang on.

Note: See TracTickets for help on using tickets.