errors and warnings / stdlib / E8122
E8122 error
An @expectError function gives other diagnostics than it names
- area
- stdlib (x8xxx)
- fails the build
- yes
A compile-time test marked @expectError doesn't fail to compile the way it
says. The checker collects the error codes reported inside the function, plus
any warning codes the decorator names, and compares them with the decorator's
list. When the two match, those diagnostics are dropped and the test passes.
When they don't, E8122 shows what was expected and what was reported. Fix the
function so that it gives exactly the listed diagnostics, or fix the list.
Example
import expectError from "wowlua:test" @expectError("E2001")local function wrongArgument() local n: number = 3 print(n)endimport expectError from "wowlua:test" @expectError("E2001")local function wrongArgument() local n: number = "3" print(n)endThe compiler reports it like this:
error[E8122]: `wrongArgument` should not compile with E2001; it gives none ┌─ tests/main.test.wowlua:3:1 │ 3 │ @expectError("E2001") │ ^^^^^^^^^^^^^^^^^^^^^ expected here
Related codes
| code | message |
|---|---|
| E8120 | A @cases case does not match the test function's parameters |
Offline
$ wowlua explain E8122 E8122 (error): An @expectError function gives other diagnostics than it names