You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dereferencing operator . on struct field access (#5538)
## Description
This PR implements struct field access operator `.` for
[references](https://github.com/FuelLabs/sway-rfcs/blob/ironcev/amend-references/files/0010-references.sw).
The overall effort related to references is tracked in #5063.
`.` is defined for references to structs using this recursive
definition: `<reference>.<field name> := (*<reference>).<field name>`.
This eliminates the need for the dereferencing operator `*` when working
with references to structs:
```Sway
let s = Struct { x: 0 };
let r = &&&s;
assert((***r).x == r.x);
```
```Sway
let r = &&&Struct { r_a: &&A { x: 1 }, &B { y: 2 } ];
assert(r.r_a.x == 1);
assert(r.r_b.y == 2);
```
Additionally, the PR adds a `Diagnostic` for the
`StorageFieldDoesNotExist` error and aligns it with the
`StructFieldDoesNotExist` error.
## Demo
)


## 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.
- [ ] 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.
0 commit comments