-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
scwq
instruction and "phantom" error in purity checks (#6432)
## Description This PR fixes #6320 and #6431 by: - properly treating the `scwq` instruction in purity check as a storage writing instruction. - not emitting purity issues for `__entry` functions. Additionally, the PR: - removes purity checks from the type-checking phase. Those checks were: - redundant. The same checks were also done at the IR side. - incomplete. The checks were covering only the function and method calls, not other kinds of storage access (e.g., intrinsics). - inaccurate. The checks were relying on `#[storage]` attributes, which do not necessary represent actual storage access patterns. - extends `MetadataManager` to be able to store more then one `Span` per `MetadataIndex`. E.g., for a function, we can now store the span of the whole function declaration, but in addition, also the span pointing only to the function name. - removes two different and overlapping storage access mismatch errors and introduces one expressive diagnostics that points to the exact storage access violations inside of a function (see demo below). Note that having the purity tests at the IR level means that no purity errors will be reported on non-used functions. This was already the case before, since the complete set of tests was done at the IR level, and only two tests (inaccurately) at the type-checking phase, where errors would be reported even for the non-used functions. The purity guaranty is given for all the compiled code. Closes #6320. Closes #6431. ## Demo Before, we had two different error messages, rendered potentially several times per access violation. ![Before 01 - Storage attribute access mismatch](https://github.com/user-attachments/assets/1207b640-2742-4cee-afa9-da9cfc743e2c) ![Before 02 - Function performs storage read](https://github.com/user-attachments/assets/284f9a65-fc6c-4318-ab83-5beab730b4d3) Now, we have only one error message that points to the access violations and explains them. ![After 01 - Pure function cannot access storage](https://github.com/user-attachments/assets/87f69493-efd2-4230-bd52-95f0ea1c6fd8) ![After 02 - Pure function cannot access storage](https://github.com/user-attachments/assets/2fd3ff3b-5738-4e46-99f9-417c4be8520d) ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
- Loading branch information
Showing
74 changed files
with
1,061 additions
and
368 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
Oops, something went wrong.