errors and warnings / classes / E3042
E3042 error
Field and method/accessor with the same name (in a class or across its superclass)
- area
- classes (x3xxx)
- fails the build
- yes
A field and a method (or accessor) with the same name, in one class or across a class and its superclass. An instance has one value per name, so the field would hide the method. Rename one of them.
Example
class Unit function label(): string return "x" endendclass Player extends Unit label: string = "y"endprint(Player)class Unit function label(): string return "x" endendclass Player extends Unit title: string = "y"endprint(Player)The compiler reports it like this:
error[E3042]: `label` is a field in one class and a method or accessor in the other ┌─ src/main.wowlua:7:5 │ 2 │ function label(): string │ ----- inherited member · 7 │ label: string = "y" │ ^^^^^ here
Related codes
| code | message |
|---|---|
| E3046 | A field declared twice in one class (a constructor's parameter property included) |
Offline
$ wowlua explain E3042 E3042 (error): Field and method/accessor with the same name (in a class or across its superclass)