forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type check and inference issues in references, structs, and enums (…
…FuelLabs#5643) ## Description This PR: - fixes FuelLabs#5559, FuelLabs#5597, and FuelLabs#5492 by removing the `TypeInfo::Unknown` and providing the required contextual information to type checking of referencing, dereferencing, `if`, and `match` expressions respectively. The contextual information provided is taken from the `ctx.type_annotation()` but always adapted according to the semantics of the type-checked expression. - fixes FuelLabs#5583 and FuelLabs#5581 by combining the contextual information coming from the `ctx.type_annotation()` with the one coming from the enum and struct instantiation and declaration. - fixes FuelLabs#5598 by forcing the name-based and not structure-based identity. In other words, two enums or structs are considered equal only if they whole `call_path`s are equal. Up to now, we were expecting only the enum or struct _names_ to be equal, which was treating types with same names and structures (variants or fields) as equal although they were defined in different modules. The PR also introduces parsing of references to mutable values (`&mut T`). Since this addition does not overlap with the above bug fixes, it was left as is, and can be fully ignored during the review. Other changes related to references to mutable values are removed from the code from type-checking onward to make this PR only fixing the issues. Continuation on references to mutable values will be done in a separate PR. Closes FuelLabs#5559, FuelLabs#5597, FuelLabs#5492, FuelLabs#5583, FuelLabs#5581, FuelLabs#5598. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [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
65 changed files
with
1,893 additions
and
362 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
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.