-
Notifications
You must be signed in to change notification settings - Fork 24
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
@@ -445,7 +449,7 @@ object Transformer extends Phase[Typechecked, CoreTransformed] { | |||
} | |||
|
|||
val body: BlockLit = BlockLit(Nil, List(promptCapt), Nil, List(promptParam), | |||
Scope(transformedHandlers, transform(prog))) | |||
Scope(transformedHandlers, transformedProg)) | |||
|
|||
Context.bind(Reset(body)) |
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.
I am not quite sure what the transformation is that is applied here and how to incorporate the new finalizer clauses here.
@@ -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(()) }
- ^
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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.