[GHC] #15468: in ghci -fbreak-on-exception omits exception info

GHC ghc-devs at haskell.org
Thu Aug 2 18:28:27 UTC 2018


#15468: in ghci -fbreak-on-exception omits exception info
-------------------------------------+-------------------------------------
           Reporter:  George         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.8.1
          Component:  GHCi           |           Version:  8.4.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 In ghc 8.4.3

 Without -fbreak-on-exception you get a good error message:

 {{{
 ghci -ignore-dot-ghci
 GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
 Prelude> let 2 + 2 = 5
 Prelude> 2 + 2
 5
 Prelude> 3 + 3
 *** Exception: <interactive>:1:5-13: Non-exhaustive patterns in function +
 }}}

 With -fbreak-on-exception there is no info about the exception:

 {{{
  ghci -ignore-dot-ghci -fbreak-on-exception
 GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
 Prelude> let 2 + 2 = 5
 Prelude> 2 + 2
 5
 Prelude> 3 + 3
 Stopped in <exception thrown>, <unknown>
 _exception :: e = _
 [<unknown>] [<unknown>] Prelude>
 }}}

 In addition, contrary to the documentation, it doesn't seem possible to
 get ghci to print out the value of the exception

 {{{
 <unknown>] [<unknown>] Prelude> :print _exception
 _exception = (_t1::e)
 [<unknown>] [<unknown>] Prelude> :info _exception
 _exception :: e         -- Defined in ‘interactive:Ghci3’
 [<unknown>] [<unknown>] Prelude>
 }}}

 Finally the fact that you get now warning about

 {{{
 let 2 + 2 = 5
 }}}

 or for
 {{{
 2 = 3
 }}}

 makes me think I should file an ER to add the following to the default
 warnings for ghci

 {{{
  ghci -ignore-dot-ghci -Wname-shadowing -Wunused-pattern-binds
 GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
 Prelude> let 2 + 2 = 5

 <interactive>:1:7: warning: [-Wname-shadowing]
     This binding for ‘+’ shadows the existing binding
       imported from ‘Prelude’ (and originally defined in ‘GHC.Num’)
 Prelude> 2 = 3

 <interactive>:2:1: warning: [-Wunused-pattern-binds]
     This pattern-binding binds no variables: 2 = 3
 Prelude>
 }}}

 I noticed the second and when googling to see if it had been reported I
 came across the following which documented the first:
 https://code.likeagirl.io/2-2-5-and-why-compiler-warnings-are-good-
 eaadef327146

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


More information about the ghc-tickets mailing list