errors and warnings / names / E1010
E1010 error
Assignment to an exported or imported binding
- area
- names (x1xxx)
- fails the build
- yes
- in plain Lua files
- reported as W1010
The code assigns to an exported local after its declaration, or to an
imported name. Importers copy an export once while the file loads, so a
later assignment would never reach them; exported and imported bindings are
therefore read-only. Change a table's contents instead (state.count += 1),
or export functions that read and change the value.
Example
export local count = 0count = count + 1export local state = { count = 0 }state.count = state.count + 1The compiler reports it like this:
error[E1010]: cannot assign to the exported binding `count`; mutate a table's contents or export accessor functions ┌─ src/main.wowlua:2:1 │ 2 │ count = count + 1 │ ^^^^^ here
Related codes
| code | message |
|---|---|
| E2010 | Assignment to a const, readonly field, read-only accessor, enum member or wowlua:meta field |
| E0119 | export local without an initializer |
Offline
$ wowlua explain E1010 E1010 (error): Assignment to an exported or imported binding