If you do something like this in Rust:
struct Foo {
x: u8
}
impl Foo {
fn method(&self) {
let y = x;
}
}
Then rustc gives a really nice diagnostic that tells you you probably meant to access self.x:
error[E0425]: cannot find value `x` in this scope
--> src/main.rs:7:17
|
7 | let y = x;
| ^
|
help: you might have meant to use the available field
|
7 | let y = self.x;
| +++++
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=00fc5f337e983eeedfdcaab2d70df558
We should add a similar suggestion to our unresolved-reference diagnostic in situations like this:
class Foo:
x: int
def method(self):
y = x