-
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.
Merge branch 'master' into jjcnn/move-external-modules-to-root
- Loading branch information
Showing
21 changed files
with
167 additions
and
32 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
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_fail/array_oob_reassignment/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 = "array_oob_reassignment" | ||
source = "member" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "core" | ||
source = "path+from-root-CC73096846C1E083" |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_fail/array_oob_reassignment/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,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "array_oob_reassignment" | ||
entry = "main.sw" | ||
implicit-std = false | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../sway-lib-core" } |
16 changes: 16 additions & 0 deletions
16
test/src/e2e_vm_tests/test_programs/should_fail/array_oob_reassignment/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,16 @@ | ||
script; | ||
|
||
fn main() { | ||
let mut a = [u64; 0]; | ||
a[0] = 1; | ||
|
||
|
||
let mut b = [[u64; 1]; 1]; | ||
b[0][1] = 1; | ||
|
||
|
||
b[1][0] = 1; | ||
|
||
|
||
a[0] = return; | ||
} |
19 changes: 19 additions & 0 deletions
19
test/src/e2e_vm_tests/test_programs/should_fail/array_oob_reassignment/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,19 @@ | ||
category = "fail" | ||
|
||
# check: $()let mut a = [u64; 0]; | ||
# nextln: $()This declaration is never used. | ||
|
||
# check: $()let mut b = [[u64; 1]; 1]; | ||
# nextln: $()This declaration is never used. | ||
|
||
# check: $()a[0] = 1; | ||
# nextln: $()Index out of bounds; the length is 0 but the index is 0. | ||
|
||
# check: $()b[0][1] = 1; | ||
# nextln: $()Index out of bounds; the length is 1 but the index is 1. | ||
|
||
# check: $()b[1][0] = 1; | ||
# nextln: $()Index out of bounds; the length is 1 but the index is 1. | ||
|
||
# check: $()a[0] = return; | ||
# nextln: $()Index out of bounds; the length is 0 but the index is 0. |
13 changes: 13 additions & 0 deletions
13
...st_programs/should_pass/language/references/mutability_of_references_memcpy_bug/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,13 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-1F6D5E67DD060824" | ||
|
||
[[package]] | ||
name = "mutability_of_references_memcpy_bug" | ||
source = "member" | ||
dependencies = ["std"] | ||
|
||
[[package]] | ||
name = "std" | ||
source = "path+from-root-1F6D5E67DD060824" | ||
dependencies = ["core"] |
8 changes: 8 additions & 0 deletions
8
...st_programs/should_pass/language/references/mutability_of_references_memcpy_bug/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 <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "mutability_of_references_memcpy_bug" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../reduced_std_libs/sway-lib-std-assert" } |
19 changes: 19 additions & 0 deletions
19
...t_programs/should_pass/language/references/mutability_of_references_memcpy_bug/src/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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
library; | ||
|
||
#[inline(never)] | ||
pub fn unit(b: u256) -> u256 { | ||
b | ||
} | ||
|
||
#[inline(never)] | ||
pub fn weird(_b: u256) { | ||
let mut b = _b; // b = _b = 2 | ||
|
||
log(b); | ||
|
||
let mut b_tmp = b; // b_tmp = b = 2 | ||
|
||
b = 0x03u256; // b = a = 1 | ||
|
||
assert(unit(b_tmp) == 0x02u256); | ||
} |
27 changes: 27 additions & 0 deletions
27
..._programs/should_pass/language/references/mutability_of_references_memcpy_bug/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,27 @@ | ||
contract; | ||
|
||
pub mod lib; | ||
|
||
use ::lib::weird; | ||
|
||
abi MyContract { | ||
fn test_function(b: u256) -> u256; | ||
} | ||
|
||
impl MyContract for Contract { | ||
|
||
fn test_function(_b: u256) -> u256 { | ||
weird(_b); | ||
0x00u256 | ||
} | ||
} | ||
|
||
|
||
|
||
#[test] | ||
fn test() { | ||
let caller = abi(MyContract, CONTRACT_ID); | ||
let b = 0x02u256; | ||
|
||
let _ = caller.test_function(b); | ||
} |
3 changes: 3 additions & 0 deletions
3
...st_programs/should_pass/language/references/mutability_of_references_memcpy_bug/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 = "unit_tests_pass" | ||
validate_abi = false | ||
expected_warnings = 0 |