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.
Fix access to tuples in structs (FuelLabs#907)
* fixing tuple access in structs * improving a comment Co-authored-by: Mohammad <[email protected]>
- Loading branch information
1 parent
10a78cf
commit 53ecab4
Showing
7 changed files
with
90 additions
and
13 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
13 changes: 13 additions & 0 deletions
13
test/src/e2e_vm_tests/test_programs/tuple_in_struct/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 = 'git+http://github.com/FuelLabs/sway-lib-core?reference=master#c331ed20ebc9d646acec6b8ee8f408627ce3b573' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'git+http://github.com/FuelLabs/sway-lib-std?reference=master#7081d2e1ac2401f22a0de0673e8a01535180ba3a' | ||
dependencies = ['core git+http://github.com/FuelLabs/sway-lib-core?reference=master#c331ed20ebc9d646acec6b8ee8f408627ce3b573'] | ||
|
||
[[package]] | ||
name = 'tuple_in_struct' | ||
dependencies = ['std git+http://github.com/FuelLabs/sway-lib-std?reference=master#7081d2e1ac2401f22a0de0673e8a01535180ba3a'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/tuple_in_struct/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] | ||
author = "Fuel Labs <[email protected]>" | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "tuple_in_struct" | ||
|
||
[dependencies] | ||
std = { git = "http://github.com/FuelLabs/sway-lib-std" } |
1 change: 1 addition & 0 deletions
1
test/src/e2e_vm_tests/test_programs/tuple_in_struct/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 @@ | ||
[] |
55 changes: 55 additions & 0 deletions
55
test/src/e2e_vm_tests/test_programs/tuple_in_struct/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,55 @@ | ||
script; | ||
use std::chain::*; | ||
|
||
struct W { | ||
t5: u64, | ||
t6: (u8, u8, (u64, u8), u16), | ||
} | ||
|
||
struct T { | ||
t3: (u8, u8), | ||
t4: u16 | ||
} | ||
|
||
struct S { | ||
t0: W, | ||
t1: (u64, u64), | ||
t2: T, | ||
} | ||
|
||
struct U { | ||
u: u64 | ||
} | ||
|
||
fn main() -> bool { | ||
let s = S { | ||
t0: W { | ||
t5: 5, | ||
t6: (6, 7, (8, 9), 10) | ||
}, | ||
t1: (0, 1), | ||
t2: T { | ||
t3: (2, 3), | ||
t4: 4 | ||
} | ||
}; | ||
|
||
assert((s.t1).0 == 0); | ||
assert((s.t1).1 == 1); | ||
assert((s.t2.t3).0 == 2); | ||
assert((s.t2.t3).1 == 3); | ||
assert(s.t2.t4 == 4); | ||
assert(((s.t0).t5) == 5); | ||
assert(((s.t0).t6).0 == 6); | ||
assert(((s.t0).t6).1 == 7); | ||
assert((((s.t0).t6).2).0 == 8); | ||
assert((((s.t0).t6).2).1 == 9); | ||
assert(((s.t0).t6).3 == 10); | ||
|
||
let u = U { | ||
u: 22 | ||
}; | ||
assert(u.u == 22); | ||
|
||
true | ||
} |