Opened 9 years ago

Closed 8 years ago

#2500 closed bug (fixed)

Unrecognised pragma complained about twice

Reported by: simonpj Owned by: simonmar
Priority: normal Milestone: 6.12 branch
Component: Compiler Version: 6.8.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:


module Foo where

{-# FOO wibble #-}
f x = x

We get two complaints:

c:/simonpj/darcs/HEAD/ghc/stage1-inplace/ghc -c Foo.hs

Foo.hs:3:0: Unrecognised pragma

Foo.hs:3:0: Unrecognised pragma

Change History (7)

comment:1 Changed 9 years ago by igloo

However, with this module:

module Foo where

w = ()

{-# FOO wibble #-}
f x = x

we get only one warning. I haven't checked, but I'm pretty sure that what's happening here is that the first warning is given when we are looking for OPTIONS and LANGUAGE pragmas, and the second warning is given when we are actually parsing the module for real.

I don't think we should get rid of the first warning, e.g. with:


module Foo where

z = ()

#if FOO
q = q
w = w

it's the only one we get:

q.hs:2:0: Unrecognised pragma

q.hs:8:1: lexical error at character 'i'

But not giving the second warning is hard. Personally I'd be tempted to leave things as they are; thoughts?

comment:2 Changed 9 years ago by simonpj

  • Could we not silently ignore unrecognised pragmas when searching for OPTIONS pragmas?
  • Would it be possible for the "Unrecognised pragma" message to say "Unrecognised pragma `FOO'"?


comment:3 Changed 8 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:4 Changed 8 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:5 Changed 8 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:6 Changed 8 years ago by simonmar

Owner: set to simonmar

comment:7 Changed 8 years ago by simonmar

Resolution: fixed
Status: newclosed


Tue Apr 21 03:00:39 PDT 2009  Simon Marlow <>
 * FIX #2500: Don't log warnings in getHeader

In Igloo's example we now get no warnings at all in HEAD (this was already the case before my patch). Although arguably not ideal, this is consistent with the way other warnings work: if there are any errors, no warnings are generated.

Note: See TracTickets for help on using tickets.