-
Notifications
You must be signed in to change notification settings - Fork 39
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 language specification for finally
clause
#256
base: devel
Are you sure you want to change the base?
Conversation
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.
Per discussion in #main
- the closest we got to the "everyone sort of agrees it is the way things should be" is (mostly per @alaviss, and I think I can probably agree to it as well).
- If try body exit normally and finally exit for reason R, the block exit for reason R
- If try body exit for reason S and finally exit normally, the block exit for reason S
- If try body exit abruptly for reason S and finally exit abruptly for reason R
- If S is an unhandled exception and R is not an unhandled exception, the block exit for reason S
- If S and R are unhandled exceptions, R is chained to S and the block exit for reason R -- R is chained to S (S will be the new toplevel exception in chain)
- Otherwise, the block exit for reason R and S is discarded
This would allow avoiding dropping exceptions while mostly maintaining the "finally takes priority" behavior that we have now.
NOTE: it is just a tl;dr to keep the context in place - the PR is perfectly fine as it is now, I think.
yield 1 | ||
|
||
var it = iter | ||
# TODO: what should happen here? |
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.
Per current behavior - yield
should take priority, like any other 'jump' in finally.
Per recent discussion on how things should be implemented later on - raise
should take priority.
Sure, feel free to take this over. I believe the to-do list is still up-to-date. |
Summary
This is an attempt at expanding the specification with tests for everything
finally
related. It's not in a mergeable state yet, but I thought that it might be useful already.The additions to
t06_procedure_calls.nim
are more or less structured, whilet07_finally.nim
is currently more of a dumping ground for various test cases than anything else.To-do:
finally
and both{.inline.}
and{.closure.}
iterators