
#15299: GHCi :print produces variables that cause a panic --------------------------------------+------------------------------- Reporter: Omf | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: GHCi | Version: 8.2.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: GHCi crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+------------------------------- Using ghci installed by Stack, I noted some strange behaviour from the :sprint and :print commands: {{{#!hs λ> xs = [1,2,3] λ> :sprint xs xs = _ λ> head xs 1 λ> :sprint xs xs = _ λ> :print xs xs = (_t1::Num a => [a]) λ> _t1 <interactive>:6:1: error: • No instance for (Num a) arising from a use of ‘_t1’ • In the expression: _t1 In an equation for ‘it’: it = _t1 λ> :t _t1 <interactive>:1:1: error: No instance for (Num a) arising from a use of ‘_t1’ λ> :info _t1 _t1 :: Num a => [a] -- Defined in ‘interactive:Ghci3’ λ> _t1 :: [Int] <interactive>:9:1: error:ghc: panic! (the 'impossible' happened) (GHC version 8.2.2 for x86_64-unknown-linux): No skolem info: a_a1rR 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/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} I don't really understand the error, or why even the :type command fails, but it appears to be related to the way numeric types are polymorphic until a specific type is forced. Note that the both the :sprint and :print commands don't seem to recognise that we've evaluated any of xs, just printing an underscore no matter what. The panic doesn't happen if I force a type when defining xs: {{{#!hs λ> xs = [1,2,3] :: [Int] λ> :sp xs xs = _ λ> head xs 1 λ> :sp xs xs = 1 : _ λ> :print xs xs = 1 : (_t2::[Int]) λ> _t2 [2,3] λ> :t _t2 _t2 :: [Int] λ> :in _t2 _t2 :: [Int] -- Defined in ‘interactive:Ghci6’ λ> _t2 :: [Integer] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15299 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler