-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add resource finalization to handlers #701
base: master
Are you sure you want to change the base?
Conversation
@@ -659,8 +659,17 @@ class RecursiveDescent(positions: Positions, tokens: Seq[Token], source: Source) | |||
*/ | |||
def tryExpr(): Term = | |||
nonterminal: | |||
`try` ~> stmt() ~ someWhile(handler(), `with`) match { | |||
case s ~ hs => TryHandle(s, hs) | |||
`try` ~> stmt() ~ manyWhile(handler(), `with`) ~ finalizerClause(`suspend`, false) ~ finalizerClause(`resume`, true) ~ finalizerClause(`return`, true) ~ finalizerClause(`finally`, true) match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, this breaks the current positions and error messages have the wrong span:
Warning: |[warning] examples/pos/capture/regions.effekt:10:3: Handling effect Dummy, which seems not to be used by the program.
| try { prog() } with Dummy { resume(()) }
| ^
|""".stripMargin
=> Diff (- obtained, + expected)
try { prog() } with Dummy { resume(()) }
- ^
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The changes to the inliner seem to break some tests. For example, consider the JS output for the file Without inlining
with inlining
We can see that two of the pattern matching values are missing (inlined?), however, their names still appear unbound ( |
This issue ↑ seems similar to the problem detected in #561 (comment) |
Sadly, the fix proposed in #561 (comment) does not seem to fix the failing tests for |
This was actually due to a faulty free variable function which caused some definitions used in continuations not be marked as used and consequently deleted as dead code. This was a fun debugging session 🙃 |
This PR aims to add resource finalization to handlers. This was already implemented under the branch feature/finalizer, however, the branch is now hilariously outdated and solving the merge conflicts almost impossible. Thus, I manually try to re-implement it.