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
The text was updated successfully, but these errors were encountered:
Braqzen
added
bug
Something isn't working
compiler
General compiler. Should eventually become more specific as the issue is triaged
labels
Aug 22, 2023
## Description
This PR closes#4997. The problem
here is that "asm blocks registers" without initializers are considered
uninitialized. There is no fallback to "capture" an available variable.
This could be easily done, but that would leave us with no obvious
syntax for unitialized registers.
With this in mind this PR solves the compiler bug with two diagnostics:
1 - uninitialized registers cannot be read before they are written. This
generates an error:
```
5 | let _ = asm(r1) {
| ^^ Unitialized register is being read before being written
6 | r1: u64
7 | };
```
2 - a warning when a unitialized register shadows an available variable
with the same name. This is almost for sure a problem, and it is better
the name the registe with something else and avoid all the confusion.
```
27 | let r5 = 0;
28 | asm(r5) {};
| -- This unitialized register is shadowing a variable, you probably meant to also initialize it like "r5: r5".
29 |
30 | 0
```
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] 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.
- [x] 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.
Version
0.44.0
The issue is the
len_to_hash
in the params of theasm()
.If you change
len_to_hash
tolen_to_hash: len_to_hash
it will compile.The order of the params is irrelevant.
The text was updated successfully, but these errors were encountered: