-
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.
Eliminate alias map from lexical scope (#5931)
## Description Fixes #5912, #5713 . Item imports with aliases `use x::y as z` have so far been represented using two maps: - A synonyms map mapping `y` to the type declaration of `x::y`. - An alias map mapping `z` to `y`. This is confusing, since `y` is not actually bound by this import, and unsurprisingly has lead to a bug because of a name capture (see #5713). This PR eliminates the alias mapping, and changes the synonyms map to map `z` to the type declaration of `x::y`. ## 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. - [x] 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
6 changed files
with
111 additions
and
91 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
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/aliased_imports/src/wiz.sw
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library; | ||
|
||
// Dead code analysis disabled due to a bug. | ||
// See https://github.com/FuelLabs/sway/issues/5902#issuecomment-2079212717 | ||
#[allow(dead_code)] | ||
pub struct Wiz { | ||
pub wiz: u64, | ||
} |
4 changes: 2 additions & 2 deletions
4
test/src/e2e_vm_tests/test_programs/should_pass/language/aliased_imports/test.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 42 } | ||
expected_result_new_encoding = { action = "return_data", value = "000000000000002A" } | ||
expected_result = { action = "return", value = 170 } | ||
expected_result_new_encoding = { action = "return_data", value = "00000000000000AA" } | ||
validate_abi = true |