
#10665: INLINE breaks rewrite rules when '-g' is used -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by slyfox): And here goes conduit sample: http://code.haskell.org/~slyfox/when-rules- tick-in-conduit-T10665.tar.gz (3MB of haskell code). Tarball contains original hackage packages with 2-3 language pragmas added. It does not require external depends and can be built with inplace/bin /ghc-stage2. Fails thusly on 7.10.2: {{{ $ ./trigger-a-bug.bash [97 of 99] Compiling Data.Conduit.Extra.ZipConduitSpec ( conduit-1.2.4.3/test/Data/Conduit/Extra/ZipConduitSpec.hs, conduit-1.2.4.3/test/Data/Conduit/Extra/ZipConduitSpec.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-unknown-linux): Tick in rule unstream @ a21_a4C66 @ Void @ m_a4C64 @ b_a4C65 (ConduitWithStream @ a21_a4C66 @ Void @ m_a4C64 @ b_a4C65 (let { $dApplicative_a4BDD :: Applicative (ConduitM a21_a4C66 Void m_a4C64) [LclId, Str=DmdType] $dApplicative_a4BDD = $fApplicativeConduitM @ a21_a4C66 @ Void @ m_a4C64 ($fFunctorConduitM @ a21_a4C66 @ Void @ m_a4C64) } in ... }}} To follow by source code: {{{#!hs --| rewrite rule is triggered by '$$' operator at conduit-1.2.4.3/test/Data/Conduit/Extra/ZipConduitSpec.hs: res <- src $$ conduit =$ sink --| '''conduit-1.2.4.3/Data/Conduit/List.hs''' refines rewrite rule as: {-# RULES "conduit: $$ fold" forall src f b. src $$ fold f b = connectFold src f b #-} --| '''fold''' is defined at conduit-1.2.4.3/Data/Conduit/List.hs: fold, foldC :: Monad m => (b -> a -> b) -> b -> Consumer a m b foldC f = loop where loop !accum = await >>= maybe (return accum) (loop . f accum) {-# INLINE foldC #-} STREAMING(fold, foldC, foldS, f accum) --| STREAMING is a macro in conduit-1.2.4.3/fusion-macros.h that inlines 'fold' lately: #define STREAMING(name, nameC, nameS, vars) ;\ name = nameC ;\ {-# INLINE [0] name #-} ;\ {-# RULES "unstream name" forall vars. \ name vars = unstream (streamConduit (nameC vars) (nameS vars)) \ #-} }}} Here delaying inline does not help as rewrite rule becomes broken when compliling one module (where it's defined) and used in another. That's the reson why original reproducer so carefully setups phases. To be able to compile it under windows you might need to change {{{ -D'UNIX=1' \ }}} to {{{ -D'WINDOWS=1' \ }}} in '''trigger-a-bug.bash''' script. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10665#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler