Commit 84f8e862 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

Ensure that GHC.Stack.callStack doesn't fail

Test Plan: Validate, ensure the `f7` program of `IPLocation` doesn't
crash.

Reviewers: gridaphobe, austin, hvr

Reviewed By: gridaphobe

Subscribers: rwbarton, thomie

GHC Trac Issues: #14028

Differential Revision: https://phabricator.haskell.org/D3795
parent d75bba85
......@@ -85,7 +85,10 @@ popCallStack stk = case stk of
--
-- @since 4.9.0.0
callStack :: HasCallStack => CallStack
callStack = popCallStack ?callStack
callStack =
case ?callStack of
EmptyCallStack -> EmptyCallStack
_ -> popCallStack ?callStack
{-# INLINE callStack #-}
-- | Perform some computation without adding new entries to the 'CallStack'.
......
......@@ -29,9 +29,15 @@ f6 0 = putStrLn $ prettyCallStack ?loc
f6 n = f6 (n-1)
-- recursive functions add a SrcLoc for each recursive call
f7 :: IO ()
f7 = putStrLn (prettyCallStack $ id (\_ -> callStack) ())
-- shouldn't crash. See #14043.
main :: IO ()
main = do f0
f1
f3 (\ () -> putStrLn $ prettyCallStack ?loc)
f4 (\ () -> putStrLn $ prettyCallStack ?loc)
f5 (\ () -> putStrLn $ prettyCallStack ?loc3)
f6 5
f7
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment