-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix array element type algorithm to avoid selecting never #6511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f67a0ef
fix array element type algorithm to avoid selecting never
xunilrj 2e54a71
clippy and fmt issues
xunilrj 2200ae8
fix type check test
xunilrj 7d2e15f
more tests
xunilrj c8d5155
Merge branch 'master' into xunilrj/fix-array-elem-type-alg
IGI-111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
16 changes: 16 additions & 0 deletions
16
test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/Forc.lock
This file contains hidden or 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,16 @@ | ||
[[package]] | ||
name = "array_wrong_elements_types" | ||
source = "member" | ||
dependencies = [ | ||
"core", | ||
"std", | ||
] | ||
|
||
[[package]] | ||
name = "core" | ||
source = "path+from-root-C125AFC4EC59A434" | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-C125AFC4EC59A434" | ||
dependencies = ["core"] |
10 changes: 10 additions & 0 deletions
10
test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/Forc.toml
This file contains hidden or 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,10 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
license = "Apache-2.0" | ||
name = "array_wrong_elements_types" | ||
entry = "main.sw" | ||
implicit-std = false | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../sway-lib-core" } | ||
std = { path = "../../../../../../sway-lib-std" } |
Empty file.
49 changes: 49 additions & 0 deletions
49
test/src/e2e_vm_tests/test_programs/should_fail/array_wrong_elements_types/src/main.sw
This file contains hidden or 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,49 @@ | ||
script; | ||
|
||
fn vec<T>() -> Vec<T> { | ||
Vec::new() | ||
} | ||
|
||
fn main() { | ||
// unexpected u16 | ||
let a: [u8;1] = [1u16]; | ||
|
||
// unexpected u16 | ||
let _ = [1u8, 1u16]; | ||
let a = [1, 2u8, 3u16, 4u32, 5u64]; | ||
|
||
// unexpected u8 | ||
let _ = [1, 1u16, a[0]]; | ||
|
||
// unexpected string slice | ||
let _ = [1, "", 1u8, 1u16]; | ||
|
||
// unexpected u8 | ||
let _ = [return, 1u8, 1u16]; | ||
|
||
// unexpected u16 | ||
let _ = [1u8, return, 1u16]; | ||
|
||
// unexpected u16 | ||
let _ = [1, return, 1u8, 1u16]; | ||
|
||
// unexpected str | ||
let _ = [1, "", 1u16]; | ||
let _ = [1, 2, "hello"]; | ||
let _ = [1, return, "", 1u16]; | ||
xunilrj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let _ = [1, "", return, 1u16]; | ||
|
||
// unexpected Vec<u16> | ||
let _ = [Vec::new(), vec::<u8>(), vec::<u16>()]; | ||
|
||
// unexpected Option<u8> | ||
let a = [None, Some(1), Some(1u8)]; | ||
let _b: Option<u16> = a[1]; | ||
|
||
// unexpected u8 | ||
let a = [8, 256u16, 8u8]; | ||
let b: u32 = a[2]; | ||
|
||
// Should not warn or error | ||
let _ : [u8 ; 0] = []; | ||
} | ||
xunilrj marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.