-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix the scope of
recover()
(#1672)
<!-- please provide a detailed description of the changes made in this pull request. --> ## High level overview Addresses #1656. This is meant to bring achieve parity between gno and go's `recover` functionality. The new tests help to ensure this. BREAKING CHANGE: this will break any realm code that has relies on the incorrect `recover` implementation ### Changes For the convenience of the reviewer, here are the categories of changes that have been made: - the `recover` function has been modified to determine whether a panic can be recovered; this is based on both the "level" of nested defer statements and the frame from which the panic was initiated - `Frame`s are now stored as pointers to avoid copying frame values as they are tracked by the `Exception`s that have been thrown - a new `Exception` type has been defined to encapsulate both the panic string and the frame in which it was initiated - the machine has two new "scope" member variables for tracking levels of `panic` and `defer` - added safety mechanisms to retrieving frames because we may not always want it to panic when trying to retrieve a call frame at an index that exceeds the stack depth - the gno standard library's `testing` package's `Recover` function no longer works as intended; the tests have been modified to achieve the intended behavior - various new file tests have been added to ensure `recover` behaves as expected in certain edge cases <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
- Loading branch information
Showing
17 changed files
with
304 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.