diff --git a/effectful-core/CHANGELOG.md b/effectful-core/CHANGELOG.md index 446ea07e..3c4cf165 100644 --- a/effectful-core/CHANGELOG.md +++ b/effectful-core/CHANGELOG.md @@ -1,6 +1,7 @@ # effectful-core-2.3.1.0 (????-??-??) * Remove inaccurate information from the `Show` instance of `ErrorWrapper`. * Add `Effectful.Provider.List`, generalization of `Effectful.Provider`. +* Respect `withFrozenCallStack` used by callers of `send`. # effectful-core-2.3.0.1 (2023-11-13) * Prevent internal functions from appending call stack frames to handlers. diff --git a/effectful-core/src/Effectful/Internal/Utils.hs b/effectful-core/src/Effectful/Internal/Utils.hs index 919d8288..e78b7348 100644 --- a/effectful-core/src/Effectful/Internal/Utils.hs +++ b/effectful-core/src/Effectful/Internal/Utils.hs @@ -186,5 +186,5 @@ newUnique = Unique <$> newByteArray 0 thawCallStack :: CallStack -> CallStack thawCallStack = \case - FreezeCallStack cs -> thawCallStack cs + FreezeCallStack cs -> cs cs -> cs diff --git a/effectful/tests/ErrorTests.hs b/effectful/tests/ErrorTests.hs index 74d4b06e..e362519e 100644 --- a/effectful/tests/ErrorTests.hs +++ b/effectful/tests/ErrorTests.hs @@ -6,10 +6,12 @@ import Test.Tasty.HUnit import Effectful import Effectful.Dispatch.Dynamic import Effectful.Error.Static +import qualified Effectful.Error.Dynamic as D errorTests :: TestTree errorTests = testGroup "Error" [ testCase "different handlers are independent" test_independentHandlers + , testCase "call stack of dynamic throwError doesn't show internal details" test_dynamicThrowErrorCallStack ] test_independentHandlers :: Assertion @@ -21,6 +23,13 @@ test_independentHandlers = runEff $ do "outerThrow" == fst (last $ getCallStack cs) Right _ -> assertFailure "error caught by the wrong (inner) handler" +test_dynamicThrowErrorCallStack :: Assertion +test_dynamicThrowErrorCallStack = do + Left (cs, ()) <- runEff . D.runError @() $ D.throwError () + case getCallStack cs of + [("throwError", _)] -> pure () + _ -> assertFailure $ "invalid call stack: " ++ prettyCallStack cs + ---------------------------------------- -- Helpers