This repository was archived by the owner on Apr 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Clarify delegate targetting function-level block #177
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,8 +288,7 @@ end | |
If `call $foo` throws, searching for a catching block first finds `delegate`, | ||
and because it delegates exception handling to catching instructions associated | ||
with `$l1`, it will be next checked by the outer `catch` and then `catch_all` | ||
instructions. When the specified label within a `delegate` instruction does not | ||
correspond to a `try` instruction, it is a validation failure. | ||
instructions. | ||
|
||
Note that the example below is a validation failure: | ||
``` | ||
|
@@ -311,6 +310,39 @@ catching instructions (`catch`/`catch_all`/`delegate`) come after the | |
same as if the `try` has catches but none of the catches are able to handle the | ||
exception. | ||
|
||
If `delegate`'s immediate argument is the depth of block-like structures | ||
(blocks, loops, and trys) + 1, i.e., the function-level block, it is considered | ||
to be delegating the exception to the caller of the current function. For | ||
example: | ||
``` | ||
try $l1 | ||
try | ||
call $foo | ||
delegate 1 ;; delegate to the caller | ||
catch | ||
... | ||
catch_all | ||
... | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the example complete I think it should be wrapped in a function, otherwise it is ambiguous what the outer scope is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
``` | ||
In case `foo` throws, `delegate 1` here delegates the exception handling to the | ||
caller, i.e., the exception escapes the current function. | ||
|
||
When the specified label within a `delegate` instruction does not correspond to | ||
a `try` instruction or the function-level, it is a validation failure: | ||
``` | ||
block $l0 | ||
loop $l1 | ||
try | ||
call $foo | ||
delegate $l0 ;; targets a 'block', validation failure | ||
try | ||
call $foo | ||
delegate $l1 ;; targets a 'loop', validation failure | ||
end | ||
end | ||
``` | ||
|
||
### JS API | ||
|
||
#### Stack traces | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't understand what you mean by: "the depth of block-like structures (...) + 1" and how this is related to the function-level block case. Or did you mean that in this case the depth is not a block-like structure?
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 understand what you meant now. What do you think about this phrasing: "the depth of the outermost block + 1, i.e. the function-level block (...)"
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.
Done. Also added that it will be considered as a catchless try.