errors and warnings / stdlib / E8102
E8102 error
saved.bind name is not a string literal
- area
- stdlib (x8xxx)
- fails the build
- yes
saved.bind takes the SavedVariable's name as a string literal, so the
compiler can check it against the manifest (E8020) and make sure it is bound
only once (E8103). A variable or any other expression can't be checked.
Write the name directly in the call.
Example
{ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["MyAddonDB"] }}import * as saved from "wowlua:saved"local name = "MyAddonDB"local db = saved.bind(name, { version = 1, defaults = {} })print(db){ "package": { "name": "playground", "version": "0.1.0", "wowlua": "^0.13" }, "flavors": { "camelot": {} }, "addon": { "saved-variables": ["MyAddonDB"] }}import * as saved from "wowlua:saved"local db = saved.bind("MyAddonDB", { version = 1, defaults = {} })print(db)The compiler reports it like this:
error[E8102]: `saved.bind` needs the SavedVariable's name as a string literal ┌─ src/main.wowlua:3:23 │ 3 │ local db = saved.bind(name, { version = 1, defaults = {} }) │ ^^^^ not a literal
Related codes
| code | message |
|---|---|
| E8020 | saved.bind on a SavedVariable not declared in the manifest |
| E8103 | SavedVariable bound twice with saved.bind |
Offline
$ wowlua explain E8102 E8102 (error): saved.bind name is not a string literal