-
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.
better error messages for slice in constants
- Loading branch information
Showing
10 changed files
with
208 additions
and
39 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
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_fail/slice/slice_intrinsics/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,8 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-53D6DC514F06A250" | ||
|
||
[[package]] | ||
name = "slice_intrinsics" | ||
source = "member" | ||
dependencies = ["core"] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_fail/slice/slice_intrinsics/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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <contact@fuel.sh>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "slice_intrinsics" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
25 changes: 25 additions & 0 deletions
25
test/src/e2e_vm_tests/test_programs/should_fail/slice/slice_intrinsics/json_abi_oracle.json
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,25 @@ | ||
{ | ||
"configurables": [], | ||
"functions": [ | ||
{ | ||
"attributes": null, | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"types": [ | ||
{ | ||
"components": null, | ||
"type": "u64", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
..._tests/test_programs/should_fail/slice/slice_intrinsics/json_abi_oracle_new_encoding.json
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,26 @@ | ||
{ | ||
"configurables": [], | ||
"encoding": "1", | ||
"functions": [ | ||
{ | ||
"attributes": null, | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"messagesTypes": [], | ||
"types": [ | ||
{ | ||
"components": [], | ||
"type": "()", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
28 changes: 28 additions & 0 deletions
28
test/src/e2e_vm_tests/test_programs/should_fail/slice/slice_intrinsics/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,28 @@ | ||
script; | ||
|
||
// slice cannot be consts | ||
const GLOBAL_ARRAY: [u64; 5] = [1, 2, 3, 4, 5]; | ||
const GLOBAL_SLICE: &__slice[u64] = __slice(GLOBAL_ARRAY, 0, 5); | ||
|
||
fn main() { | ||
// slice cannot be consts | ||
const LOCAL_ARRAY: [u64; 5] = [1, 2, 3, 4, 5]; | ||
const LOCAL_SLICE: &__slice[u64] = __slice(LOCAL_ARRAY, 0, 5); | ||
|
||
// Wrong start index | ||
let a: [u64; 5] = [1, 2, 3, 4, 5]; | ||
let _ = __slice(a, 6, 7); | ||
|
||
// Wrong end index | ||
let a: [u64; 5] = [1, 2, 3, 4, 5]; | ||
let _ = __slice(a, 0, 6); | ||
|
||
// Wrong first argument | ||
__slice(0, 0, 0); | ||
|
||
// Wrong start index | ||
__slice(0, "", 0); | ||
|
||
// Wrong end index | ||
__slice(0, 0, ""); | ||
} |
26 changes: 26 additions & 0 deletions
26
test/src/e2e_vm_tests/test_programs/should_fail/slice/slice_intrinsics/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,26 @@ | ||
category = "fail" | ||
|
||
# check: let _ = __slice(a, 6, 7) | ||
# nextln: $()Index out of bounds; the length is 5 but the index is 6. | ||
|
||
# check: let _ = __slice(a, 0, 6) | ||
# nextln: $()Index out of bounds; the length is 5 but the index is 6. | ||
|
||
# check: __slice(0, 0, 0) | ||
# nextln: $()Unsupported argument type to intrinsic "slice" | ||
|
||
# check: __slice(0, "", 0) | ||
# nextln: $()Mismatched types | ||
# nextln: $()expected: u64 | ||
# nextln: $()found: str | ||
|
||
# check: __slice(0, 0, "") | ||
# nextln: $()Mismatched types | ||
# nextln: $()expected: u64 | ||
# nextln: $()found: str | ||
|
||
# check: &__slice[u64] = __slice(GLOBAL_ARRAY, 0, 5) | ||
# nextln: $()slices or types containing slices on `const` are not allowed | ||
|
||
# check: &__slice[u64] = __slice(LOCAL_ARRAY, 0, 5) | ||
# nextln: $()slices or types containing slices on `const` are not allowed |
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