[Pkg-haskell-maintainers] Bug#635113: Generated code fails to compile: uses bang patterns without corresponding {-# LANGUAGE BangPatterns #-} pragma

Josh Triplett josh at joshtriplett.org
Sat Jul 23 01:01:40 UTC 2011


On Sat, Jul 23, 2011 at 08:37:56AM +1000, Erik de Castro Lopo wrote:
> Josh Triplett wrote:
> 
> > Package: alex
> > Version: 2.3.5-2
> > Severity: grave
> > 
> > The fix for bug 623067 makes alex -g use bang patterns, but doesn't add
> > the corresponding BangPatterns extension to the list of extensions in
> > the LANGUAGE pragma at the top of the file.  This makes the generated
> > code fail to compile:
> > 
> > dist/build/apters/apters-tmp/Scanner.hs:294:18:
> >     Illegal bang-pattern (use -XBangPatterns):
> >     ! (base)
> 
> Any idea which file is it that is missing this pragma? I've just
> looked at the patch (which I generated) and it does add the pragma
> to alex-2.3.5/src/Scan.x.
> 
>     --- alex-2.3.5.orig/src/Scan.x
>     +++ alex-2.3.5/src/Scan.x
>     @@ -11,7 +11,7 @@
>      -------------------------------------------------------------------------------
>  
>      {
>     -{-# OPTIONS_GHC -w #-}
>     +{-# OPTIONS_GHC -w -XBangPatterns #-}
>  
>      module Scan(lexer, AlexPosn(..), Token(..), Tkn(..), tokPosn) where
> 
> I'm quite a regular user of alex and I'm surprised I haven't run
> into this yet.

That looks like Alex's own lexer, used to build Alex; adding
BangPatterns there seems like the wrong fix, and it *only* fixes Alex
itself, not other users of Alex.  Instead, Alex should automatically add
{-# LANGUAGE BangPatterns #-} to the generated lexer (or rather, extend
the existing LANGUAGE pragma to include BangPatterns) when it uses
BangPatterns (specifically, when using -g).  That would avoid forcing
the project that uses Alex to know that it needs BangPatterns
internally.

Projects using Cabal automatically invoke alex with -g when building
with GHC, so this change breaks any project using Cabal and Alex (or any
other project using -g).  A quick search turns up various build logs
(from Debian packages and otherwise) of lexers failing to build with
this error.

Also, I hope that the fixed version of this patch can go upstream to fix
other users of alex, since otherwise a project building on Debian and
using -Wall -Werror will fail to build when not using Debian alex.

- Josh Triplett





More information about the Pkg-haskell-maintainers mailing list