Opened 7 years ago

Closed 6 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: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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
sh-2.04$ 

Change History (7)

comment:1 Changed 7 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:

{-# OOPS_TYPO_LANGAUGE CPP #-}

module Foo where

z = ()

#if FOO
q = q
#else
w = w
#endif

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 7 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'"?

Simon

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:5 Changed 6 years ago by igloo

  • Milestone changed from 6.10 branch to 6.12 branch

comment:6 Changed 6 years ago by simonmar

  • Owner set to simonmar

comment:7 Changed 6 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Fixed:

Tue Apr 21 03:00:39 PDT 2009  Simon Marlow <[email protected]>
 * 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.