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 tuple element access (#5552)
## Description
This PR implements tuple element 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 tuples using this recursive definition:
`<reference>.<element index> := (*<reference>).<element index>`.
This eliminates the need for the dereferencing operator `*` when working
with references to tuples:
```Sway
let t = (1, 2, 3);
let r = &&&t;
assert((***r).0 == r.0);
```
```Sway
let r = &&& ( &&(1, 2), &(3, 4) );
assert(r.0.0 == 1);
assert(r.1.1 == 4);
```
Additionally, the PR:
- creates `Diagnostic` for the `TupleIndexOutOfBounds` error.
- harmonizes the appearance of the `TupleIndexOutOfBounds` error in the
element access and reassignments.
## Demo
`TupleIndexOutOfBounds` in element access and reassignments before:

New errors:


## 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