[GHC] #14371: ghc: panic! when reloading file with code

GHC ghc-devs at haskell.org
Wed Oct 18 21:37:38 UTC 2017


#14371: ghc: panic! when reloading file with code
-------------------------------------+-------------------------------------
        Reporter:  xvrbka1           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      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:                    |
-------------------------------------+-------------------------------------
Description changed by xvrbka1:

Old description:

> Hello,
>
> I have no idea what causes it (maybe my mistake) so I probably will give
> you more code then necessaty. Sorry for that.
>  \\
> **I had working code:**
>
> {{{
> f :: [[Bool]] -> ([Bool], [[Bool]])
> f [] = ([True], g [])
> f (x:xs) = (g x, g xs)
>
> g :: [a] -> [a]
> g [] = []
> g x = x
>
> listITE :: [Bool] -> [a] -> [a] -> [a]
> listITE [] _ _ = []
> listITE _ _ [] = []
> listITE _ [] _ = []
> listITE (b:bs) (x:xs) (y:ys) = [(if b then x else y)] ++ listITE bs xs ys
> --zipWith (\x,y -> if  ) ;
>
> firstMatch :: (a -> a -> Bool) -> [a] -> a -> a
> firstMatch _ [] y = y
> firstMatch p (x:s) y =  if index >= (length (x:s)) then y  else (x:s) !!
> index
>                             where index = indexOf True (zipWith p (x:s)
> s)
>
> indexOf :: (Eq a) => a -> [a] -> Int
> indexOf _ [] = 10
> indexOf c (x:s) = if c==x then 0 else 1 + indexOf c s
> }}}
> that I could load, run and reload.
> \\
>
> **
> After I wrote this and tried to reload:**
> {{{
> countInversions :: (Ord a) => [a] -> Int
> countInversions [] = 0
> countInversions (x:s) = (countSame (True==) (map (x>) s)) +
> countInversions s
>
> countSame :: (Ord a) => (a -> Bool) [a] -> Int
> countSame _ [] = 0;
> countSame p (x:s) = (if p x then 1 else 0) + indexOf c s
>
> }}}
> \\
>
> **I get error:**\\
>
> ''ghc: panic! (the 'impossible' happened)
>   (GHC version 8.2.1 for x86_64-unknown-linux):
>         repSplitAppTys
>   a_a6Xb[sk:1]
>   Bool
>   []
>   Call stack:
>       CallStack (from HasCallStack):
>         prettyCurrentCallStack, called at
> compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
>         callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in
> ghc:Outputable
>         pprPanic, called at compiler/types/Type.hs:808:9 in ghc:Type''
> \\
> Now I cannot reaload or even load this file (but when I remove the added
> part, everything is OK)
> \\
>

> I hope I found u a bug :)
> \\
>

> Have a nice day
>
> ps. with my playing I discover that
>
> == **THIS GIVES THE ERROR** \\
>
> {{{
>
> countSame :: (Ord a) => (a -> Bool) [a] -> Int
> countSame _ [] = 0;
> countSame p (x:s) = (if p x then 1 else 0) + indexOf c s
> }}}
> \\And works OK when header is gone

New description:

 Hello,

 \\
 **
 This code:**
 {{{
 countSame :: (Ord a) => (a -> Bool) [a] -> Int
 countSame _ [] = 0;
 countSame p (x:s) = (if p x then 1 else 0) + (countSame p s)
 }}}
 \\

 **gives me an error:**\\

 ''ghc: panic! (the 'impossible' happened)
   (GHC version 8.2.1 for x86_64-unknown-linux):
         repSplitAppTys
   a_a6Xb[sk:1]
   Bool
   []
   Call stack:
       CallStack (from HasCallStack):
         prettyCurrentCallStack, called at
 compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
         callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in
 ghc:Outputable
         pprPanic, called at compiler/types/Type.hs:808:9 in ghc:Type''
 \\

 - All works when header is gone.
 - I put this code in separate file and error still occurs so it should not
 have any dependencies.


 I hope I found u a bug :)
 \\
 Have a nice day

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14371#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list