Ticket #230 (new defect)

Opened 10 months ago

Last modified 6 months ago

setup haddock ignores LANGUAGE CPP pragma

Reported by: ross@soi.city.ac.uk Assigned to:
Priority: normal Milestone: Cabal-2.0
Component: Cabal library Version: 1.2.3.0
Severity: normal Keywords:
Cc: Difficulty: normal
GHC Version: 6.8.2 Platform:

Description

setup haddock preprocesses sources with cpp if CPP is included in the extensions field, but not if a source file starts with

{-# LANGUAGE CPP #-}

This is confusing, because that works with setup build.

Change History

(follow-up: ↓ 2 ) 02/04/08 15:56:52 changed by duncan

  • milestone set to Cabal-2.0.

Of course that's because it is GHC that interprets the {-# LANGUAGE CPP #-} pragma and not Cabal.

Long term I think Cabal should notice LANGUAGE pragmas. It'd allow it to check that all extensions are declared in the .cabal file and it'd allow Cabal to do the cpping itself rather than using ghc's cpp.

I'm assigning it to milestone 2.0 because it should be easy enough if we're already reading .hs files to do module chasing.

(in reply to: ↑ 1 ) 02/04/08 16:19:07 changed by ross@soi.city.ac.uk

Distribution.Simple.Hugs.getOptionsFromSource may be useful.

06/09/08 16:54:19 changed by duncan

And of course we have the same problem with {-# OPTIONS -fglasgow-exts -cpp #-} which is generated by alex. So even if you didn't realise you use CPP, if you use alex then you do and then haddock fails because we don't run cpp on that file. So if we go looking for LANGUAGE pragmas then we'd also have to do the same for OPTIONS (and OPTIONS_*) pragmas.

Seems that getOptionsFromSource gets those too which is nice. Perhaps we should just do that for every file in builds and when haddocking.