Skip to content

Misleading error message on mising BangPatterns extension

For following program I'm getting an unexpected error message.

foo :: Int -> Int
foo = bar
  where
    bar :: Int -> Int
    bar !i = i
$ ghc -o Test Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )

Test.hs:4:5: error:
    The type signature for ‘bar’ lacks an accompanying binding
  |
4 |     bar :: Int -> Int
  |     ^^^

Enabling -XBangPatterns fixes the issue but I wanted the compiler to suggest me to enable it:

$ ghc -XBangPatterns -o Test Test.hs
[1 of 1] Compiling Main             ( Test.hs, Test.o )

Test.hs:1:1: error:
    The IO action ‘main’ is not defined in module ‘Main’
  |
1 | foo :: Int -> Int
  | ^
Trac metadata
Trac field Value
Version 8.4.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information