Why this fires¶
Inside an accessor, self.<same-field> means the public property and would
invoke that accessor again forever. Use the contextual name field to read or
write the stored backing slot.
struct Account {
balance: int {
get {
return self.balance // error[TE145]
}
}
}Fix it¶
Replace the recursive access with field:
get {
return field
}The diagnostic includes a machine-applicable edit for this replacement.
Accessing a different field through self remains valid and follows that
field's accessor normally.