[GHC] #12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?)

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This is a bug in an old ghc (7.4.2), documenting it here mostly in case anybody else comes across it. If you try to compile http://hackage.haskell.org/package/bytestring-builder-0.10.8.1.0 /bytestring-builder-0.10.8.1.0.tar.gz , ghc fails with {{{ src/Data/ByteString/Builder/Prim.hs:553:13: Illegal bang-pattern (use -XBangPatterns): ! br' }}} However, that file contains a directive {{{#!hs {-# LANGUAGE CPP, BangPatterns, ScopedTypeVariables #-} }}} at the very top of the file, so we should not be getting this error message. Now here's the bizarre thing: if we compile with `cabal --builddir=foo`, compilation happens as normal! I ran ghc with `--keep- tmp-files`, and compared the output of CPP for both variations, and literally the ''only'' difference between the two that lines {{{ # 156 "./dist/build/autogen/cabal_macros.h" }}} in one are {{{ # 156 "./foo/build/autogen/cabal_macros.h" }}} in the other. It gets weirder. I replaced the output of `src/Data/ByteString/Builder/Prim.hs` with the output of `cpp`, and removed the `CPP` language directive. If I start with the version that has `dist` (i.e., the one that results in a compilation error), ''even adding or removing a single blank line in the header of the file made the parser error go away'' (where the "header" is the bit with lines such as {{{ # 134 "./dist/build/autogen/cabal_macros.h" }}} No idea what's going on here; probably not worth investigating further. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): It's a bug in the lexer that was subsequently fixed. See also https://github.com/haskell/cabal/issues/3739#issuecomment-244950926 and https://github.com/ghc/ghc/commit/c250f93bd38c7d8f6453dd79dd9951f9a02bf5a7 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by edsko): Aha, I see. That makes sense. Do you have any suggested workarounds? Just found another package that suffers from the same problem: http://hackage.haskell.org/package/primitive-0.6.1.0/primitive-0.6.1.0.tar.g... . -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by edsko): Hmmm {{{ package bytestring-builder ghc-options: -XBangPatterns package primitive ghc-options: -XMagicHash }}} is a work-around. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): Well, you can certainly jiggle around the preprocessor output until the lexer accepts it correctly, but the particular output depends a lot on system configuration so someone else might run into the issue. hvr has suggested that if you increase the default buffer size much larger, you're unlikely to run into the problem, but that requires a recompile of GHC. Another possibility is to put all the LANGUAGE flags in a single pragma so there is only one `{-` token to lex. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12655: Bizarre parser problem: "Illegal bang-pattern" (something to do with CPP?) -------------------------------------+------------------------------------- Reporter: edsko | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.4.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => fixed Comment: This is a bug in an old version of GHC (and one that's been fixed at that), and a workaround has been documented. Closing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12655#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC