Skip to content

"Tick in rule" impossible error in 8.10.1-alpha2 using Megaparsec.

Summary

A parser I'm working on that uses Megaparsec (either 7.0.5 or 8.0.0) is failing to compile under the pre-release of 8.10.1 with an "impossible" error.

Steps to reproduce

I have stripped it down to the following:

module TickInRule where  
  
import Control.Monad (void)  
import Text.Megaparsec  
import Text.Megaparsec.Char  
  
foo :: String -> Parsec () String ()  
foo s = do  
   manyTill (foo "a") (lookAhead $ void (string s) <|> eof)  
   void (string s)  

(This parser doesn't make much sense of course, but I've removed everything not necessary for the error.)

I get this using ghc -O2 bad.hs:

[1 of 1] Compiling TickInRule       ( bad.hs, bad.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.10.0.20191210:
	Tick in rule
  src<libraries/base/GHC/Base.hs:(1448,1)-(1453,15)>
  src<libraries/base/Data/List/NonEmpty.hs:(187,1)-(190,51)>
  src<libraries/base/GHC/Base.hs:(1403,1)-(1418,26)> lvl_s3lT
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1179:37 in ghc:Outputable
        pprPanic, called at compiler/specialise/Rules.hs:720:5 in ghc:Rules

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Oddly, factoring out the void part (let v = void (string s)) makes the error go away; indeed, so does factoring out just string s.

Using no optimization or even -O also results in no error.

This is as far as I've gotten.

Environment

  • GHC version used: ghc-8.10.0.20191210-x86_64-deb9-linux-dwarf
Edited by Galen Huntington
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information