Skip to content

ASSERT failed! file coreSyn/CorePrep.lhs line 669

This is exposed by running the testsuite on a stage2 compiler with -DDEBUG. The tests triggering it are:

  • simplCore/should_compile/simpl014

The affected context is:

etaExpandRhs :: CoreBndr -> CoreExpr -> UniqSM CoreExpr
etaExpandRhs bndr rhs = do
   	-- Eta expand to match the arity claimed by the binder
	-- Remember, CorePrep must not change arity
	--
	-- Eta expansion might not have happened already, 
	-- because it is done by the simplifier only when 
	-- there at least one lambda already.
	-- 
	-- NB1:we could refrain when the RHS is trivial (which can happen
	--     for exported things).  This would reduce the amount of code
	--     generated (a little) and make things a little words for
	--     code compiled without -O.  The case in point is data constructor
	--     wrappers.
	--
	-- NB2: we have to be careful that the result of etaExpand doesn't
	--    invalidate any of the assumptions that CorePrep is attempting
	--    to establish.  One possible cause is eta expanding inside of
	--    an SCC note - we're now careful in etaExpand to make sure the
	--    SCC is pushed inside any new lambdas that are generated.
	--
	-- NB3: It's important to do eta expansion, and *then* ANF-ising
	--		f = /\a -> g (h 3)	-- h has arity 2
	-- If we ANF first we get
	--		f = /\a -> let s = h 3 in g s
	-- and now eta expansion gives
	-- 		f = /\a -> \ y -> (let s = h 3 in g s) y
	-- which is horrible.
	-- Eta expanding first gives
	--		f = /\a -> \y -> let s = h 3 in g s y
	--
    us <- getUniquesM
    let eta_rhs = etaExpand arity us rhs (idType bndr)

    ASSERT2( manifestArity eta_rhs == arity, (ppr bndr <+> ppr arity <+> ppr (exprArity rhs)) 
					      $$ ppr rhs $$ ppr eta_rhs )
	-- Assertion checks that eta expansion was successful
      return eta_rhs
  where
	-- For a GlobalId, take the Arity from the Id.
	-- It was set in CoreTidy and must not change
	-- For all others, just expand at will
    arity | isGlobalId bndr = idArity bndr
	  | otherwise	    = exprArity rhs

The precise error is:

ghc-6.9.20080614: panic! (the 'impossible' happened)
  (GHC version 6.9.20080614 for i386-apple-darwin):
	ASSERT failed! file coreSyn/CorePrep.lhs line 669
main:ShouldCompile.runHandler{v r6G} [gid] 3 3
__inline_me ((\ (@ st{tv a73} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d})
                (w{v si9} [lid] :: main:ShouldCompile.M{tc r7}
                                     (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv]))
                (w1{v sia} [lid] :: main:ShouldCompile.IHandler{tc r8}
                                      st{tv a73} [tv])
                (eta{v sj4} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                       ghc-prim:GHC.Prim.RealWorld{(w) tc 31E})
                (eta1{v sjb} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                        ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}) ->
                main:ShouldCompile.$wrunHandler{v r2} [gid]
                  @ st{tv a73} [tv] w1{v sia} [lid] eta1{v sjb} [lid])
             `cast` (ghc-prim:GHC.Prim.trans{(w) tc 34y}
                       (forall st{tv a73} [tv].
                        main:ShouldCompile.M{tc r7}
                          (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                        -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                        -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                             ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                        -> ghc-prim:GHC.Prim.CoUnsafe{(w) tc 34K}
                             (ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                      ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                    base:GHC.Base.(){(w) tc 40} #))
                             (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                  ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                base:GHC.Base.(){(w) tc 40} #))
                       (forall st{tv a73} [tv].
                        main:ShouldCompile.M{tc r7}
                          (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                        -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                        -> ghc-prim:GHC.Prim.sym{(w) tc 34v}
                             ((base:GHC.IOBase.:CoIO{tc reo}) base:GHC.Base.(){(w) tc 40}))
                     :: <pred>forall st{tv a73} [tv].
                              main:ShouldCompile.M{tc r7}
                                (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                              -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                              -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                   ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                   ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                      ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                    base:GHC.Base.(){(w) tc 40} #)
                                ~
                              forall st{tv a73} [tv].
                              main:ShouldCompile.M{tc r7}
                                (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                              -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                              -> <nt>base:GHC.IOBase.IO{tc 32I} base:GHC.Base.(){(w) tc 40}))
__inline_me ((\ (@ st{tv a73} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d})
                (w{v si9} [lid] :: main:ShouldCompile.M{tc r7}
                                     (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv]))
                (w1{v sia} [lid] :: main:ShouldCompile.IHandler{tc r8}
                                      st{tv a73} [tv])
                (eta{v sj4} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                       ghc-prim:GHC.Prim.RealWorld{(w) tc 31E})
                (eta1{v sjb} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                        ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}) ->
                main:ShouldCompile.$wrunHandler{v r2} [gid]
                  @ st{tv a73} [tv] w1{v sia} [lid] eta1{v sjb} [lid])
             `cast` (ghc-prim:GHC.Prim.trans{(w) tc 34y}
                       (forall st{tv a73} [tv].
                        main:ShouldCompile.M{tc r7}
                          (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                        -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                        -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                             ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                        -> ghc-prim:GHC.Prim.CoUnsafe{(w) tc 34K}
                             (ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                      ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                    base:GHC.Base.(){(w) tc 40} #))
                             (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                  ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                base:GHC.Base.(){(w) tc 40} #))
                       (forall st{tv a73} [tv].
                        main:ShouldCompile.M{tc r7}
                          (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                        -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                        -> ghc-prim:GHC.Prim.sym{(w) tc 34v}
                             ((base:GHC.IOBase.:CoIO{tc reo}) base:GHC.Base.(){(w) tc 40}))
                     :: <pred>forall st{tv a73} [tv].
                              main:ShouldCompile.M{tc r7}
                                (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                              -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                              -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                   ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                   ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}
                              -> (# ghc-prim:GHC.Prim.State#{(w) tc 32q}
                                      ghc-prim:GHC.Prim.RealWorld{(w) tc 31E},
                                    base:GHC.Base.(){(w) tc 40} #)
                                ~
                              forall st{tv a73} [tv].
                              main:ShouldCompile.M{tc r7}
                                (main:ShouldCompile.IHR{tc r6} st{tv a73} [tv])
                              -> main:ShouldCompile.IHandler{tc r8} st{tv a73} [tv]
                              -> <nt>base:GHC.IOBase.IO{tc 32I} base:GHC.Base.(){(w) tc 40}))

It appears to occur because the exprArity of the RHS (i.e. the value of arity variable above) is less than its manifest arity.

Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information