Skip to content

Show warning when file-header pragma is used after module keyword

Consider the following file:

{-# LANGUAGE NOINLINE foo bar #-}
module Main where

main :: IO ()
main = return ()

We'd expect this error to occur:

$  ~/ghc/ghc-work/inplace/bin/ghc-stage2 --interactive /tmp/tester.hs
GHCi, version 7.7.20130624: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.

/tmp/tester.hs:1:14: Unsupported extension: NOINLINE
Failed, modules loaded: none.
Prelude> 

Now consider:

module Main where
{-# LANGUAGE NOINLINE foo bar #-}
main :: IO ()
main = return ()

And:

~/ghc/ghc-work/inplace/bin/ghc-stage2 --interactive /tmp/tester.hs
GHCi, version 7.7.20130624: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( /tmp/tester.hs, interpreted )
Ok, modules loaded: Main.
*Main> 

Something like this actually slipped into base and was fixed. See Gabor's commit 100c051 which fixed it.

I was going to attempt to fix this myself but I (probably rightly) backed away a little as I understand the code more. This ticket can keep track of it, regardless of who fixes it.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure InvalidProgramAccepted
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Thomas Miedema
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information