Bang pattern in expression error with NoBangPatterns
Summary
The compiler produces a fatal error complaining about a bang pattern in an expression (not a pattern) even when BangPatterns
is not enabled.
Steps to reproduce
The following module:
{-# LANGUAGE NoBangPatterns #-}
module Bang where
import Data.Map (Map, (!))
lookups :: (Ord k) => k -> [Map k v] -> [v]
lookups k = map (!k)
produces an error
Bang.hs:7:18: error: [GHC-95644]
Bang pattern in expression context: !k
Did you mean to add a space after the '!'?
|
7 | lookups k = map (!k)
|
Expected behavior
The expression is legal in Haskell 98 and Haskell 2010. If the user is operating is a language subset without bang patterns, it should be accepted. Even with bang patterns enabled, perhaps it should only be a warning.
Environment
- GHC versions used: 9.0.2, 9.2.4, 9.5.20221202
Optional:
- Operating System:
- System Architecture: