errors and warnings / parsing / E0112
E0112 error
const without an initializer, or declaring several names
- area
- parsing (x01xx)
- fails the build
- yes
A const has no = value, or declares several names (const A, B = 1, 2).
A constant can't be assigned later, so it needs its value where it is
declared, and each const declares one name. Use one const per value, or
local for a value that is set later.
Example
const MAX_ITEMSprint(MAX_ITEMS)const MAX_ITEMS = 40print(MAX_ITEMS)The compiler reports it like this:
error[E0112]: `const` needs an initializer ┌─ src/main.wowlua:1:1 │ 1 │ const MAX_ITEMS │ ^^^^^^^^^^^^^^^ here
Related codes
| code | message |
|---|---|
| E2010 | Assignment to a const, readonly field, read-only accessor, enum member or wowlua:meta field |
Offline
$ wowlua explain E0112 E0112 (error): const without an initializer, or declaring several names