v0.13.7
errors and warnings / types

errors and warnings / types / E2014

E2014 error

Type argument does not satisfy its constraint

area
types (x2xxx)
fails the build
yes
in plain Lua files
reported as W2014

A type parameter declared with extends was given a type that doesn't satisfy its constraint. Type arguments are inferred from the call, so this usually means an argument of the wrong type: a list of strings where items with a size are needed, or a key that isn't one of the table's fields for K extends keyof T.

Example

× failswowlua
local function largest<T extends { size: number }>(xs: T[]): T    return xs[1]endprint(largest({ "a", "b" }))
✓ compileswowlua
local function largest<T extends { size: number }>(xs: T[]): T    return xs[1]endprint(largest({ { size = 1 } }))

The compiler reports it like this:

error[E2014]: `string` does not satisfy the constraint `{ size: number }` of `T`
  ┌─ src/main.wowlua:4:7
  │
4 │ print(largest({ "a", "b" }))
  │       ^^^^^^^^^^^^^^^^^^^^^ here
codemessage
E2013Wrong number of type arguments
E2001Type mismatch: S is not assignable to T

Offline

terminal
$ wowlua explain E2014
E2014 (error): Type argument does not satisfy its constraint

source on GitHub ↗