Skip to content
ZOLO / TE145 Type · error

recursive access to the same field from its accessor

Accessing `self.<same-field>` inside its accessor would recurse; use the contextual backing name `field`.

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.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br