[GHC] #13658: Assertion failure on HEAD: "optCoercion changed types!"
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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: -------------------------------------+------------------------------------- I am seeing the following assertion failure on my `wip/libdw-prof` branch, {{{ ghc-stage1: panic! (the 'impossible' happened) (GHC version 8.3.20170507 for x86_64-unknown-linux): ASSERT failed! optCoercion changed types! in_co: (base:Data.Typeable.Internal.TypeRep{tc 35W} (UnsafeCo nominal ghc-prim:GHC.Types.Any{(w) tc 35K} (ghc- prim:GHC.Types.Any{(w) tc 35K} -> ghc- prim:GHC.Types.Any{(w) tc 35K})) (UnsafeCo nominal (ghc-prim:GHC.Types.Any{(w) tc 35K} ghc-prim:GHC.Types.Any{(w) tc 35K}) ghc- prim:GHC.Types.Any{(w) tc 35K}))_R in_ty1: base:Data.Typeable.Internal.TypeRep{tc 35W} (ghc-prim:GHC.Types.Any{(w) tc 35K} ghc-prim:GHC.Types.Any{(w) tc 35K}) in_ty2: base:Data.Typeable.Internal.TypeRep{tc 35W} ghc-prim:GHC.Types.Any{(w) tc 35K} out_co: (base:Data.Typeable.Internal.TypeRep{tc 35W} (UnsafeCo nominal ghc-prim:GHC.Types.Any{(w) tc 35K} (ghc- prim:GHC.Types.Any{(w) tc 35K} -> ghc- prim:GHC.Types.Any{(w) tc 35K})) <ghc-prim:GHC.Types.Any{(w) tc 35K}>_N)_R out_ty1: base:Data.Typeable.Internal.TypeRep{tc 35W} ghc-prim:GHC.Types.Any{(w) tc 35K} out_ty2: base:Data.Typeable.Internal.TypeRep{tc 35W} ghc-prim:GHC.Types.Any{(w) tc 35K} subst: [TCvSubst In scope: InScope {wild_00{v} base:Data.Typeable.Internal.mkTrCon{v 088} base:Data.Typeable.Internal.mkTrApp{v 089} base:Data.Typeable.Internal.typeNatTypeRep{v 08a} base:Data.Typeable.Internal.typeSymbolTypeRep{v 08b} base:Data.Typeable.Internal.mkTrFun{v 08d} wild_X3j{v} wild_X7E{v} wild_X83{v} wild_Xf1{v} dt_X2TF{v} a{v X2UX} kind_vars{v X2V3} kind_vars{v X32p} n{v a2Oo} a{v a2OX} b{v a2OY} tc{v a2Pw} args{v a2Px} tc{v a2PH} args{v a2PI} kind_args{v a2PK} ty_args{v a2PL} ty'{v a2PQ} dt_a2TG{v} dt_a2TH{v} k{tv a402} a{tv a403} k{tv a43q} k{tv a43r} k{tv a43s} a{tv a43t} $cshowsPrec{v a46O} $cshow{v a46Z} $cshowList{v a477} $cshowsPrec{v a47h} $cshow{v a47n} $cshowList{v a47t} $ccompare{v a47F} $c<{v a47X} $c<={v a485} $c>{v a48d} $c>={v a48l} $cmax{v a48t} $cmin{v a48B} $c=={v a48J} $c/={v a48Z} $ccompare{v a49d} $c<{v a49o} $c<={v a49u} $c>{v a49A} $c>={v a49G} $cmax{v a49M} $cmin{v a49S} $ctestEquality{v a4a1} $c=={v a4as} $c/={v a4aw} $krep_a4cI{v} $krep_a4cJ{v} $krep_a4cK{v} $krep_a4cL{v} $krep_a4cM{v} $krep_a4cN{v} $krep_a4cO{v} $krep_a4cP{v} $krep_a4cQ{v} $krep_a4cR{v} $krep_a4cS{v} $krep_a4cT{v} $krep_a4cU{v} $krep_a4cV{v} $krep_a4cW{v} $krep_a4cX{v} $krep_a4cY{v} $krep_a4cZ{v} $krep_a4d0{v} $krep_a4d1{v} $krep_a4d2{v} $krep_a4d3{v} $krep_a4d4{v} $krep_a4d5{v} $krep_a4d6{v} $krep_a4d7{v} $krep_a4d8{v} $krep_a4d9{v} $krep_a4da{v} $krep_a4db{v} $krep_a4dc{v} $krep_a4dd{v} $krep_a4de{v} $krep_a4df{v} $krep_a4dg{v} $krep_a4dh{v} $krep_a4di{v} $krep_a4dj{v} $krep_a4dk{v} $krep_a4dl{v} $krep_a4dm{v} $krep_a4dn{v} $krep_a4do{v} $krep_a4dp{v} $krep_a4dq{v} $krep_a4dr{v} $krep_a4ds{v} go{v a54a} wild{v a54c} y{v a54g} ys{v a54h} ds_d4tk{v} ds_d4tl{v} ds_d4tm{v} ds_d4tn{v} ds_d4to{v} ds_d4tS{v} ds_d4vc{v} dt_d52H{v} dt_d52I{v} base:Data.Typeable.Internal.modulePackage{v r2LC} base:Data.Typeable.Internal.moduleName{v r2LD} base:Data.Typeable.Internal.tyConPackage{v r2LE} base:Data.Typeable.Internal.tyConModule{v r2LF} base:Data.Typeable.Internal.tyConName{v r2LG} base:Data.Typeable.Internal.trNameString{v r2LH} base:Data.Typeable.Internal.tyConFingerprint{v r2LI} base:Data.Typeable.Internal.tyConKindArgs{v r2LJ} base:Data.Typeable.Internal.tyConKindRep{v r2LK} base:Data.Typeable.Internal.rnfModule{v r2LL} base:Data.Typeable.Internal.rnfTrName{v r2LM} base:Data.Typeable.Internal.rnfKindRep{v r2LN} base:Data.Typeable.Internal.rnfList{v r2LP} base:Data.Typeable.Internal.rnfTyCon{v r2LR} base:Data.Typeable.Internal.typeRepFingerprint{v r2LT} base:Data.Typeable.Internal.withTypeable{v r2LU} base:Data.Typeable.Internal.someTypeRepTyCon{v r2LV} base:Data.Typeable.Internal.typeRepTyCon{v r2LW} base:Data.Typeable.Internal.eqTypeRep{v r2LX} base:Data.Typeable.Internal.typeRepKind{v r2LY} base:Data.Typeable.Internal.runtimeRepTypeRep{v r2M6} base:Data.Typeable.Internal.typeRep{v r2M9} base:Data.Typeable.Internal.typeOf{v r2Ma} base:Data.Typeable.Internal.someTypeRep{v r2Mb} base:Data.Typeable.Internal.someTypeRepFingerprint{v r2Mc} base:Data.Typeable.Internal.splitApps{v r2Me} base:Data.Typeable.Internal.funTyCon{v r2Mf} base:Data.Typeable.Internal.rnfTypeRep{v r2Mj} base:Data.Typeable.Internal.rnfSomeTypeRep{v r2Mk} base:Data.Typeable.Internal.mkTyCon#{v r2Mm} base:Data.Typeable.Internal.mkTyCon{v r2Mn} base:Data.Typeable.Internal.mkTyConFingerprint{v r2Mo} base:Data.Typeable.Internal.mkTypeLitFromString{v r2Mq} base:Data.Typeable.Internal.tcSymbol{v r2Mr} base:Data.Typeable.Internal.tcNat{v r2Ms} base:Data.Typeable.Internal.$tc'SomeTypeRep{v r2RW} base:Data.Typeable.Internal.$tcSomeTypeRep{v r2Sy} base:Data.Typeable.Internal.$tc'TrTyCon{v r2SA} base:Data.Typeable.Internal.$tc'TrApp{v r2SO} base:Data.Typeable.Internal.$tc'TrFun{v r2T2} base:Data.Typeable.Internal.$tcTypeRep{v r2Tg} base:Data.Typeable.Internal.$fShowSomeTypeRep{v r2Ug} base:Data.Typeable.Internal.$fShowTypeRep{v r2Ul} base:Data.Typeable.Internal.$fOrdSomeTypeRep{v r2UJ} base:Data.Typeable.Internal.$fEqSomeTypeRep{v r2US} base:Data.Typeable.Internal.$fOrdTypeRep{v r2UX} base:Data.Typeable.Internal.$fTestEqualitykTypeRep{v r2Vf} base:Data.Typeable.Internal.$fEqTypeRep{v r2Vp} base:Data.Typeable.Internal.$tc'SomeKindedTypeRep{v r2VB} base:Data.Typeable.Internal.$tcSomeKindedTypeRep{v r2VW} base:Data.Typeable.Internal.$tcTypeable{v r2Wg} base:Data.Typeable.Internal.$tc'C:Typeable{v r2Wh} base:Data.Typeable.Internal.$tc'Gift{v r2Wm} base:Data.Typeable.Internal.$tcGift{v r2WP} base:Data.Typeable.Internal.$mKindRepTypeLit{v r3DI} base:Data.Typeable.Internal.$bKindRepTypeLit{v r3IP} base:Data.Typeable.Internal.$mCon'{v r3LL} base:Data.Typeable.Internal.$mCon{v r3Ns} base:Data.Typeable.Internal.$mApp{v r3NA} base:Data.Typeable.Internal.$bApp{v r3Oi} base:Data.Typeable.Internal.$mFun{v r3Om} base:Data.Typeable.Internal.$bFun{v r3Sq} base:Data.Typeable.Internal.$trModule{v r43m} rnfString_s573{v} typeOf_s5bk{v} $trModule_s5bF{v} $trModule_s5bH{v} $krep_s5bP{v} $krep_s5bQ{v} $tcTypeRep_s5bR{v} $tcTypeRep_s5bS{v} $krep_s5bT{v} $krep_s5bU{v} $krep_s5bV{v} $krep_s5bW{v} $krep_s5bX{v} $krep_s5bY{v} $krep_s5bZ{v} $krep_s5c0{v} $tc'TrApp_s5c1{v} $tc'TrApp_s5c2{v} $krep_s5c3{v} $krep_s5c4{v} $krep_s5c5{v} $krep_s5c6{v} $krep_s5c7{v} $krep_s5c8{v} $tc'TrFun_s5c9{v} $tc'TrFun_s5ca{v} $tcSomeTypeRep_s5cb{v} $tcSomeTypeRep_s5cc{v} $tc'SomeTypeRep_s5cd{v} $tc'SomeTypeRep_s5ce{v} $krep_s5cg{v} $tc'TrTyCon_s5ch{v} $tc'TrTyCon_s5ci{v} $tcSomeKindedTypeRep_s5cj{v} $tcSomeKindedTypeRep_s5ck{v} $krep_s5cl{v} $tc'SomeKindedTypeRep_s5cm{v} $tc'SomeKindedTypeRep_s5cn{v} $tcTypeable_s5co{v} $tcTypeable_s5cp{v} $tc'C:Typeable_s5cs{v} $tc'C:Typeable_s5ct{v} $tcGift_s5cu{v} $tcGift_s5cv{v} $krep_s5cw{v} $krep_s5cx{v} $krep_s5cy{v} $tc'Gift_s5cz{v} $tc'Gift_s5cA{v} $dTypeable_s5cC{v} $dTypeable_s5cE{v} $dTypeable_s5cG{v} $dTypeable_s5cI{v} $dTypeable_s5cK{v} $dTypeable_s5cM{v} $dTypeable_s5cO{v} $dTypeable_s5cQ{v} $dTypeable_s5cS{v} $dTypeable_s5cU{v} $dTypeable_s5cW{v} $dTypeable_s5cY{v} $dTypeable_s5d0{v} $dTypeable_s5d1{v} $dTypeable_s5gz{v} $dTypeable_s5gB{v} $dTypeable_s5gD{v} $dTypeable_s5gF{v} $dTypeable_s5gH{v} $dTypeable_s5gJ{v} $dTypeable_s5gL{v} $dTypeable_s5gN{v} $dTypeable_s5gP{v} $dTypeable_s5gR{v} $dTypeable_s5gT{v} $dTypeable_s5gV{v} $dTypeable_s5gX{v} $dTypeable_s5gZ{v} $dTypeable_s5h1{v} $dTypeable_s5h3{v} go{v s5pU} vars{v s5pY} lvl_s5rC{v} lvl_s5rD{v} lvl_s5rG{v} lvl_s5rJ{v} lvl_s5rM{v} lvl_s5rP{v} lvl_s5rR{v} lvl_s5rS{v} lvl_s5rT{v} lvl_s5rU{v} lvl_s5rV{v} lvl_s5rY{v} $dTypeable_s5s2{v} lvl_s5s3{v} lvl_s5s6{v} lvl_s5s7{v} lvl_s5sa{v} lvl_s5sb{v} lvl_s5sv{v} f_s5sz{v} lvl_s5sC{v} lvl_s5sH{v} f_s5sL{v} lvl_s5sM{v} lvl_s5sN{v} g_s5sP{v} lvl_s5sQ{v} f_s5sS{v} g_s5sU{v} lvl_s5sV{v} lvl_s5sW{v} lvl_s5sZ{v} lvl_s5t9{v} modl{v s5tj} lvl_s5tk{v} lvl_s5tl{v} lvl_s5tm{v} lvl_s5tv{v} lvl_s5tw{v} lvl_s5tx{v} lvl_s5tR{v} lvl_s5tS{v} lvl_s5tT{v} lvl_s5u6{v} lvl_s5un{v} lvl_s5uo{v} lvl_s5up{v} lvl_s5uq{v} lvl_s5ur{v} lvl_s5us{v} lvl_s5ut{v} lvl_s5uu{v} lvl_s5uv{v} $dTypeable_s5uK{v} lvl_s5uU{v} lvl_s5v8{v} lvl_s5v9{v} lvl_s5va{v} lvl_s5vb{v} lvl_s5vc{v} lvl_s5vg{v} lvl_s5wZ{v} kind_vars_s5x2{v} lvl_s5xf{v} $j_s5Da{v} lvl_s5Mo{v} lvl_s5Mp{v} lvl_s5Mq{v} lvl_s5Mr{v} lvl_s5Ms{v} kind_vars_s5MF{v} kind_vars_s5MG{v} lvl_s5MI{v} modl_s5Nw{v} lvl_s5OE{v} $wrnfModule{v s6s3} $wrnfTyCon{v s6sj} $wgo{v s6tn} $wtypeSymbolTypeRep{v s6uf} lvl_s6Qv{v} lvl_s6Qw{v} lvl_s6Qx{v} lvl_s6Qy{v} lvl_s6Qz{v} lvl_s6QA{v} lvl_s6QB{v} lvl_s6QC{v} lvl_s6QD{v} lvl_s6QF{v} lvl_s6QG{v} lvl_s6QI{v} lvl_s6QJ{v} lvl_s6QK{v} lvl_s6QL{v} lvl_s6QM{v} lvl_s6QN{v} lvl_s6QO{v} lvl_s6QP{v} lvl_s6QQ{v} lvl_s6QR{v} lvl_s6QS{v} lvl_s6QT{v} lvl_s6QU{v} lvl_s6QV{v} lvl_s6QW{v} lvl_s6QY{v} lvl_s6QZ{v} lvl_s6R0{v} lvl_s6R1{v} lvl_s6R2{v} lvl_s6Rb{v} lvl_s6Rd{v} lvl_s6Re{v} lvl_s6Rf{v} lvl_s6Rg{v} lvl_s6Rh{v} lvl_s6Ri{v} lvl_s6Rj{v} lvl_s6Rk{v} lvl_s6Rl{v} lvl_s6Rm{v} lvl_s6Rn{v} lvl_s6Ro{v} lvl_s6Rp{v} lvl_s6Rq{v} lvl_s6Rr{v} lvl_s6Rs{v} lvl_s6Rt{v} lvl_s6Ru{v} lvl_s6Rv{v} lvl_s6Rw{v} lvl_s6Rx{v} lvl_s6Ry{v} lvl_s6Rz{v} lvl_s6RA{v} lvl_s6RC{v} lvl_s6RD{v} lvl_s6RE{v} lvl_s6RG{v} lvl_s6RL{v} lvl_s6RM{v} lvl_s6RN{v} lvl_s6RO{v} lvl_s6RP{v} lvl_s6RQ{v} lvl_s6RR{v} lvl_s6RS{v} lvl_s6RT{v} lvl_s6RU{v} lvl_s6RV{v} lvl_s6RW{v} lvl_s6RX{v} lvl_s6RY{v} lvl_s6RZ{v} lvl_s6S0{v} lvl_s6S1{v} lvl_s6S2{v} lvl_s6S3{v} lvl_s6S4{v} lvl_s6S5{v} lvl_s6S6{v} lvl_s6S7{v} lvl_s6S8{v} lvl_s6S9{v} lvl_s6Sa{v} lvl_s6Sb{v} lvl_s6Sc{v} lvl_s6Sd{v} lvl_s6Se{v} lvl_s6Sf{v} lvl_s6Sg{v} lvl_s6Sh{v} lvl_s6Si{v} lvl_s6Sj{v} lvl_s6Sl{v} lvl_s6Sm{v} lvl_s6So{v} lvl_s6Sp{v} lvl_s6Sr{v} lvl_s6Ss{v} lvl_s6Su{v} lvl_s6Sv{v} lvl_s6Sx{v} lvl_s6Sy{v} lvl_s6SA{v} lvl_s6SB{v} lvl_s6SD{v} lvl_s6SE{v} lvl_s6SG{v} lvl_s6SH{v} lvl_s6SJ{v} lvl_s6SK{v} go{v s6SM} go{v s6SO} lvl_s6SR{v} wild_s6ST{v} ds_s6SU{v} ds_s6SV{v} ds_s6SW{v} ds_s6SX{v} nKindVars#{v s6SY} kindRep{v s6SZ} lvl_s6T8{v} lvl_s6Ta{v} $sgo{v s7lX} sc_s7lY{v} sc_s7lZ{v} sc_s7m0{v} sc_s7m1{v} sc_s7m3{v} sc_s7m5{v} $sgo{v s7m6} $s$wgo{v s7sR} $s$wgo{v s7sV} $stypeRepTyCon{v s7th} $stypeRepTyCon{v s7ti} $stypeRepTyCon{v s7tj} $srnfList{v s7tW}} Type env: [a403 :-> (a{tv a403} [tv] :: (k{tv a402} [tv] :: *)), a43r :-> (k1{tv a43r} [tv] :: (k{tv a43q} [tv] :: *)), a43t :-> (a{tv a43t} [tv] :: (k{tv a43s} [tv] :: *))] Co env: []] }}} This is with the following `build.mk`, {{{#!makefile BuildFlavour = dwarf ifneq "$(BuildFlavour)" "" include mk/flavours/$(BuildFlavour).mk endif GhcStage2HcOpts += -eventlog STRIP_CMD = : }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 slyfox): I've added a bit of debug into ASSERT. The complain is about type mismatch between in_ty1, out_ty1: {{{ in_ty1: base:Data.Typeable.Internal.TypeRep{tc 35W} (ghc-prim:GHC.Types.Any{(w) tc 35K} ghc-prim:GHC.Types.Any{(w) tc 35K}) out_ty1: base:Data.Typeable.Internal.TypeRep{tc 35W} ghc-prim:GHC.Types.Any{(w) tc 35K} }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 slyfox): The same error is also reproducible on a ghc-HEAD with this tiny '''mk/build.mk''': {{{ SRC_HC_OPTS += -g -dcore-lint -DDEBUG }}} I'll try to extract something smaller. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 slyfox): This should be self-contained example. You'll need a debugging compiler to build it. I'm not sure I've preserved kind structure of original module as core-lint detects all sorts of problems in this program. But the error is still the same. I was not able to remove foldl/foldr: the error goes away. {{{#!hs -- Bug.hs: {-# LANGUAGE TypeInType #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} {- # OPTIONS_GHC -Werror #-} {-# OPTIONS_GHC -g -O2 #-} module Bug (bug) where import Unsafe.Coerce (unsafeCoerce) undefined :: a undefined = undefined prelude_id :: a -> a prelude_id x = x prelude_foldl :: forall a b. (b -> a -> b) -> b -> [a] -> b prelude_foldl k z0 xs = prelude_foldr (\v fn -> (\z -> fn (k z v))) prelude_id xs z0 prelude_foldr :: (a -> b -> b) -> b -> [a] -> b prelude_foldr f z = go where go [] = z go (y:ys) = y `f` go ys data TypeRep (a :: k) where TrTyCon :: TypeRep (a :: k) TrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a b) data SomeTypeRep where SomeTypeRep :: forall k (a :: k). TypeRep a -> SomeTypeRep mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a :: k1 -> k2) -> TypeRep (a b) mkTrApp TrTyCon = undefined mkTrApp TrApp = undefined bug :: [a] -> SomeTypeRep bug args = prelude_foldl applyTy tycon_app args where tycon_app = SomeTypeRep TrTyCon applyTy :: SomeTypeRep -> a -> SomeTypeRep applyTy (SomeTypeRep acc) _unused = SomeTypeRep (mkTrApp (unsafeCoerce acc)) }}} {{{ $ ../"inplace/bin/ghc-stage1" -hisuf hi -osuf o -hcsuf hc -static -H32m -O -g -dcore-lint -DDEBUG -Wall -this-unit-id base-4.10.0.0 -hide- all-packages -i.. -i../libraries/base/. -i../libraries/base/dist- install/build -I../libraries/base/dist-install/build -i../libraries/base /dist-install/build/./autogen -I../libraries/base/dist- install/build/./autogen -Ilibraries/base/include -optP- DOPTIMISE_INTEGER_GCD_LCM -optP-include -optP../libraries/base/dist- install/build/./autogen/cabal_macros.h -package-id rts -package-id ghc- prim-0.5.0.0 -package-id integer-gmp-1.0.0.1 -this-unit-id base -XHaskell2010 -O2 -no-user-package-db -rtsopts -Wno-trustworthy-safe -Wno-deprecated-flags -Wnoncanonical-monad-instances -odir libraries/base/dist-install/build -hidir libraries/base/dist-install/build -stubdir libraries/base/dist-install/build -split-sections -dynamic-too -c Bug.hs -fforce-recomp ghc-stage1: panic! (the 'impossible' happened) (GHC version 8.3.20170506 for x86_64-unknown-linux): ASSERT failed! optCoercion changed types! in_co: (TypeRep (UnsafeCo nominal Any (Any -> Any)) (UnsafeCo nominal (Any Any) Any))_R in_ty1: TypeRep (Any Any) in_ty2: TypeRep Any out_co: (TypeRep (UnsafeCo nominal Any (Any -> Any)) <Any>_N)_R out_ty1: TypeRep Any out_ty2: TypeRep Any subst: [TCvSubst In scope: InScope {wild_00 wild_Xu y_a1t ys_a1u a_ayL $krep_aAd $krep_aAe $krep_aAf $krep_aAg $krep_aAh $krep_aAi $krep_aAj $krep_aAk $krep_aAl $krep_aAm undefined $tcTypeRep $tcSomeTypeRep $tc'TrTyCon $tc'TrApp $trModule $tc'SomeTypeRep bug $trModule_sB4 $trModule_sB5 $trModule_sB6 $trModule_sB7 $tcTypeRep_sB8 $tcTypeRep_sB9 $krep_sBa $krep_sBb $tc'TrTyCon_sBc $tc'TrTyCon_sBd $krep_sBe $krep_sBf $tc'TrApp_sBg $tc'TrApp_sBh $tcSomeTypeRep_sBi $tcSomeTypeRep_sBj $tc'SomeTypeRep_sBk $tc'SomeTypeRep_sBl poly_go_sBz lvl_sBA $spoly_go_sCu sc_sCv sc_sCw $spoly_go_sCx} Type env: [] Co env: []] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1134:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1189:22 in ghc:Outputable assertPprPanic, called at compiler/types/OptCoercion.hs:96:188 in ghc:OptCoercion Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1134:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1138:37 in ghc:Outputable pprPanic, called at compiler/utils/Outputable.hs:1187:5 in ghc:Outputable assertPprPanic, called at compiler/types/OptCoercion.hs:96:188 in ghc:OptCoercion }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 bgamari): The problem here appears to be that the `TyConAppCo` case of `OptCoercion.opt_univ` fires, {{{#!hs opt_univ env sym prov role oty1 oty2 | Just (tc1, tys1) <- splitTyConApp_maybe oty1 , Just (tc2, tys2) <- splitTyConApp_maybe oty2 , tc1 == tc2 = pprTrace "opt_univ(tyconapp)" (ppr tc1 <+> ppr tys1 $$ ppr tc2 <+> ppr tys2) $ let roles = tyConRolesX role tc1 arg_cos = zipWith3 (mkUnivCo prov) roles tys1 tys2 arg_cos' = zipWith (opt_co4 env sym False) roles arg_cos in mkTyConAppCo role tc1 arg_cos' }}} This emits, {{{ opt_univ(tyconapp) Any [Any -> Any, Any] Any [Any -> Any] }}} for the problematic coercion. The issue here is that we end up dropping the second argument from `tys1` due to the `zipWith`. I suspect we want to add a guard to this equation asserting that `tys1` and `tys2` are of equal lengths. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 slyfox): Slightly shorter example without foldl: {{{#!hs {-# LANGUAGE TypeInType #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE BangPatterns #-} {- # OPTIONS_GHC -Werror #-} {-# OPTIONS_GHC -g -O2 #-} module Bug (bug) where -- import GHC.Base (seq) import Unsafe.Coerce (unsafeCoerce) undefined :: a undefined = undefined data TypeRep (a :: k) where TrTyCon :: TypeRep (a :: k) TrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a b) data SomeTypeRep where SomeTypeRep :: forall k (a :: k). TypeRep a -> SomeTypeRep mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a :: k1 -> k2) -> TypeRep (a b) mkTrApp TrTyCon = undefined mkTrApp TrApp = undefined bug :: SomeTypeRep -- bug = f x -- this works bug = f (f x) where x = SomeTypeRep TrTyCon f :: SomeTypeRep -> SomeTypeRep f (SomeTypeRep acc) = SomeTypeRep (mkTrApp (unsafeCoerce acc)) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 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 bgamari): Indeed this appears to resolve the issue, {{{#!patch diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs index b1aa646a97..03e1d6cb5f 100644 --- a/compiler/types/OptCoercion.hs +++ b/compiler/types/OptCoercion.hs @@ -378,6 +378,7 @@ opt_univ env sym prov role oty1 oty2 | Just (tc1, tys1) <- splitTyConApp_maybe oty1 , Just (tc2, tys2) <- splitTyConApp_maybe oty2 , tc1 == tc2 + , equalLength tys1 tys2 -- NB: prov must not be the two interesting ones (ProofIrrel & Phantom); -- Phantom is already taken care of, and ProofIrrel doesn't relate tyconapps = let roles = tyConRolesX role tc1 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D3545 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3545 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"87ff5d4f0f812bad118600df0156f980b91191c5/ghc" 87ff5d4f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="87ff5d4f0f812bad118600df0156f980b91191c5" OptCoercion: Ensure that TyConApps match in arity Previously OptCoercion would potentially change the type of UnivCo coercions of the shape, ``` co :: TyCon arg1 ... argN ~ TyCon arg1' ... argN' ``` where the arities of the left and right applications differ. In this case we would try to zip the two argument lists, meaning that one would get truncated. One would think this could never happen since it implies we are applying the same TyCon to two different numbers of arguments. However, it does arise in the case of applications of the `Any` tycon, which arises from the typechecker (in `Data.Typeable.Internal`) where we end up with an `UnsafeCo`, ``` co :: Any (Any -> Any) Any ~ Any (Any -> Any) ``` Test Plan: Validate Reviewers: simonpj, austin, goldfire Reviewed By: simonpj Subscribers: rwbarton, thomie GHC Trac Issues: #13658 Differential Revision: https://phabricator.haskell.org/D3545 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13658 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * testcase: => simplCore/should_compile/T13658 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13658: Assertion failure on HEAD: "optCoercion changed types!" -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T13658 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3545 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged with ca76ae071d9ffb4f36fc4b59ef9fa3bf3dfe2b8a. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13658#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC