errors and warnings / stdlib / E8112
E8112 error
Slash router (router, Router:add): invalid ArgSpec, or run parameters don't match args/flags
- area
- stdlib (x8xxx)
- fails the build
- yes
The commands of a slash router (and a literal command given to
Router:add) are checked at compile time. Each entry of args must be
"string", "number" or "boolean" (with ? when optional), a list of
choice strings, or "rest" as the last one. run takes one parameter per
argument, plus one for the flags table when flags is declared, and each
typed parameter takes what its argument converts to: a number for
"number", a string for "rest", the choices' union for a list of choices,
a table of booleans for the flags.
Make run's parameters match args and flags, or fix the invalid argument
spec.
Example
import router from "wowlua:slash" local commands = router({ scale = { args = { "number" }, run = function(value: number, extra: string) print(value, extra) end },})print(commands)import router from "wowlua:slash" local commands = router({ scale = { args = { "number" }, run = function(value: number) print(value) end },})print(commands)The compiler reports it like this:
error[E8112]: `run` takes 1 parameter(s) for its arguments and flags, not 2 ┌─ src/main.wowlua:4:42 │ 4 │ scale = { args = { "number" }, run = function(value: number, extra: string) print(value, extra) end }, │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ here
Offline
$ wowlua explain E8112 E8112 (error): Slash router (router, Router:add): invalid ArgSpec, or run parameters don't match args/flags