Warn on unnecessary storage annotations
Example:
contract;
abi MyContract {
#[storage(write)] // Or any other storage annotation
fn foo() -> u64;
}
impl MyContract for Contract {
#[storage(write)] // Or any other storage annotation
fn foo() -> u64 {
0
}
}
should emit a warning saying that the annotations are not necessary.
@otrho have we decided against emitting warnings on unnecessary storage annotations? Or is this something that we want but hasn't been implemented yet? We don't seem to be emitting any warnings for the example above.
This could be a regression? I would expect the above to emit warnings and for there to already be tests to confirm. There was a lot of debate around it though, so maybe I've forgotten whether we decided otherwise.
Yeah no warning is generated with master. Could be a regression, but I think we would want the warning to be emitted? Seems like a useful warning to have because addressing makes the user code more readable.
I think there should be warnings, yeah.
Wait I do see a warning now 🤔 , but the warning does not seem that useful:
--> /Users/mohammad/Desktop/fuel/sway/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_and_use_in_library/src/main.sw:12:5
|
10 |
11 | #[storage(write)] // Or any other storage annotation
12 | fn foo() -> u64 {
| _____-
13 | | 0
14 | | }
| |_____- The 'write' storage declaration for this function is never accessed and can be removed.
15 | }
|
____
Well, it is useful but it can be improved.