[GHC] #9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: | Owner: spacekitteh spacekitteh | Status: new Type: task | Milestone: 7.10.1 Priority: normal | Version: Component: Core | Operating System: Unknown/Multiple Libraries | Type of failure: None/Unknown Keywords: | Blocked By: Architecture: | Related Tickets: Unknown/Multiple | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- It is basically the same as the standard error function but outputs a stack trace if one is available. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | spacekitteh Priority: normal | Status: new Component: Core Libraries | Milestone: 7.12.1 Resolution: | Version: Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by spacekitteh): * milestone: 7.10.1 => 7.12.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | spacekitteh Priority: normal | Status: new Component: Core Libraries | Milestone: 7.12.1 Resolution: | Version: Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by hvr): Btw, it's not as simple as just set `error = errorWithStackTrace`; there needs to be a way to recover the string passed to `error` w/o the additional stack-trace from the `ErrorCall` exception value (which currently provides the originally passed `error`-message as its payload). {{{#!hs -- |This is thrown when the user calls 'error'. The @String@ is the -- argument given to 'error'. newtype ErrorCall = ErrorCall String deriving (Eq, Ord, Typeable) instance Exception ErrorCall instance Show ErrorCall where showsPrec _ (ErrorCall err) = showString err }}} See also this short conversation for some ideas: {{{ hvr> carter: btw, was my concern regarding modifying the payload of the ErrorCall exception ever addressed? carter> nopeee! :) carter> maybe we expose a pattern synonym as the constructor name carter> and have the real constructor have an extra field for the trace? hvr> could work carter> so show will still render the full mess carter> but everyone's old code wont break carter> because unless youre explicity catching it carter> it ends up just being showed right? carter> error "fix me" carter> hvr: pattern synonyms dont need to be eneabled in the use sites right? carter> hvr: err, the only reason for that change would be backwards compat right? hvr> carter: well, actually it's a nice property to be able to recover the exact string you pass to 'error' carter> hvr: i wasn't arguing against it :) hvr> carter: regardless of backward compat carter> ok carter> so breaking change to make it have two args? carter> or hide it with patternsyn? carter> or wait a year and try again? hvr> carter: you've got one year to figure out the perfect way :) carter> fineeeee carter> solution: break everything hvr> carter: otoh, maybe by then we may have some other facility which makes this redundant }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | spacekitteh Priority: normal | Status: closed Component: Core Libraries | Milestone: Resolution: invalid | Version: Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by spacekitteh): * status: new => closed * resolution: => invalid * milestone: 7.12.1 => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | spacekitteh Priority: normal | Status: closed Component: Core Libraries | Milestone: Resolution: invalid | Version: Operating System: Unknown/Multiple | Keywords: Type of failure: None/Unknown | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by spacekitteh): Closed ticket in light of http://thread.gmane.org/gmane.comp.lang.haskell.libraries/23525/ this thread, which subsumes this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by carter): * owner: spacekitteh => * status: closed => new * resolution: invalid => Comment: this ticket is still valid for tracking this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by carter): Chris and I spent some time working on this, its actually pretty tricky to implement even a nominally simple patch for this because you quickly run into navigating figuring out where to write the boot file for cutting a recursive module loop -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9943: Replace "error" with "errorWithStackTrace" from GHC.Stack in base libs -------------------------------------+------------------------------------- Reporter: spacekitteh | Owner: Type: task | Status: closed Priority: normal | Milestone: 7.12.1 Component: Core Libraries | Version: Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #5273 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => duplicate * related: => #5273 * milestone: => 7.12.1 Comment: This program: {{{ import Control.Exception main = do Left (ex@(ErrorCallWithLocation a b)) <- try $ print (head [] :: ()) putStrLn a putStrLn b throwIO ex }}} Now prints: {{{ Prelude.head: empty list CallStack: error, called at libraries/base/GHC/List.hs:1009:3 in base:GHC.List Test: Prelude.head: empty list }}} I'm not sure why the custom exception handler is needed. Perhaps that will be cleared up later. I think this ticket can be closed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9943#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC