errors and warnings / types / E2010
E2010 error
Assignment to a const, readonly field, read-only accessor, enum member or wowlua:meta field
- area
- types (x2xxx)
- fails the build
- yes
- in plain Lua files
- reported as W2010
The target can't be assigned: a const, a readonly field (outside its
initializer and its own class's constructor), an accessor with a getter but no
setter, an enum member, or a field of wowlua:meta (build, flavor,
config and the others, which the compiler folds into the code). Use a
local if the value has to change, add a setter, or move the assignment into
the constructor.
Example
const MAX = 5MAX = 6local max = 5max = 6print(max)The compiler reports it like this:
error[E2010]: cannot assign to the constant `MAX` ┌─ src/main.wowlua:2:1 │ 2 │ MAX = 6 │ ^^^ here
Related codes
| code | message |
|---|---|
| E2011 | Access to a private / protected member |
Offline
$ wowlua explain E2010 E2010 (error): Assignment to a const, readonly field, read-only accessor, enum member or wowlua:meta field