Skip to content

Commit

Permalink
Respect withFrozenCallStack used by callers of send
Browse files Browse the repository at this point in the history
Fixes regression introduced by b92dc37.
  • Loading branch information
arybczak committed Dec 16, 2023
1 parent 02ce340 commit 3a37012
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions effectful-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion effectful-core/src/Effectful/Internal/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,5 @@ newUnique = Unique <$> newByteArray 0

thawCallStack :: CallStack -> CallStack
thawCallStack = \case
FreezeCallStack cs -> thawCallStack cs
FreezeCallStack cs -> cs
cs -> cs
9 changes: 9 additions & 0 deletions effectful/tests/ErrorTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 3a37012

Please sign in to comment.