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.
Adds visibility check for fully qualified function (FuelLabs#4241)
## Description The issue was that it was possible to call private methods in another module by calling them with fully qualified paths. The fix was to use resolve_call_path_with_visibility_check instead of resolve_call_path. Closes FuelLabs#4231. ## 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. - [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. --------- Co-authored-by: Mohammad Fawaz <[email protected]>
- Loading branch information
1 parent
0cafc16
commit fd94ccc
Showing
12 changed files
with
42 additions
and
6 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
2 changes: 1 addition & 1 deletion
2
test/src/e2e_vm_tests/test_programs/should_fail/generics_not_supported/src/inner_lib.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
library inner_lib; | ||
|
||
const C = 42; | ||
pub const C = 42; | ||
|
||
pub fn func() -> bool { | ||
true | ||
|
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_fail/private_function_fully_qualified/Forc.lock
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,3 @@ | ||
[[package]] | ||
name = 'private_function_fully_qualified' | ||
source = 'member' |
6 changes: 6 additions & 0 deletions
6
test/src/e2e_vm_tests/test_programs/should_fail/private_function_fully_qualified/Forc.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "private_function_fully_qualified" | ||
entry = "main.sw" | ||
implicit-std = false |
7 changes: 7 additions & 0 deletions
7
test/src/e2e_vm_tests/test_programs/should_fail/private_function_fully_qualified/src/main.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,7 @@ | ||
script; | ||
|
||
dep pkga; | ||
|
||
fn main() { | ||
pkga::foo(); | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_fail/private_function_fully_qualified/src/pkga.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,3 @@ | ||
library pkga; | ||
|
||
fn foo() { } |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_fail/private_function_fully_qualified/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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "fail" | ||
|
||
# check: $()Symbol "foo" is private. |
2 changes: 1 addition & 1 deletion
2
...c/e2e_vm_tests/test_programs/should_pass/language/use_full_path_names/src/b_dependency.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
library bar; | ||
|
||
enum Bar { | ||
pub enum Bar { | ||
Baz: bool, | ||
} |
2 changes: 1 addition & 1 deletion
2
...c/e2e_vm_tests/test_programs/should_pass/language/use_full_path_names/src/c_dependency.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
library baz; | ||
|
||
fn return_1() -> u32 { | ||
pub fn return_1() -> u32 { | ||
1u32 | ||
} |
2 changes: 1 addition & 1 deletion
2
test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/multiple_impl/src/testlib.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
library testlib; | ||
|
||
fn foo() { | ||
pub fn foo() { | ||
log(1); | ||
} |