Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RefExceptions catchable in IOSim #607

Merged
merged 5 commits into from
Mar 5, 2025
Merged

Make RefExceptions catchable in IOSim #607

merged 5 commits into from
Mar 5, 2025

Conversation

jorisdral
Copy link
Collaborator

RefExceptions are currently thrown from IO, but we can not catch these exceptions in IOSim. This PR makes changes to ensure we can catch (almost all) exceptions in any monad that has the right constraints. The only exceptions we still can't catch outside of IO are exceptions thrown by the DeRef pattern.

Copy link
Collaborator

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement. Just some suggestions below for dropping fewer checks, and trying to retain clarity a bit.

Double release checks in the `DeRef` pattern will throw exceptions in `IO`,
which we can't catch in `IOSim`. To improve reliability of catching
`RefException`s in `IOSim`, we remove the forgotten refs check from the `DeRef`
pattern.
This improves reliability of catching `RefException`s in `IOSim`. In `IOSim`, we
can not catch exceptions that were thrown in `IO`.
This serves as a sanity check for the changes introduced by previous commits
Now that we use `unsafeIOToPrim` on a more granular level, some side effects
like clearing the `globalForgottenRef` were not happening at the right time.
Adding a stricter `unsafeIOToPrimStrict` version seems to help.
Copy link
Collaborator

@dcoutts dcoutts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dcoutts dcoutts added this pull request to the merge queue Mar 5, 2025
Merged via the queue into main with commit ec24627 Mar 5, 2025
27 checks passed
@dcoutts dcoutts deleted the jdral/iosim-refs branch March 5, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants