Skip to content

The type of keys used to index [] tables is not checked #2610

Open
@mycroftjr

Description

@mycroftjr

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

Some warning should be raised if you use [5] on a table<string, x>, for example.

Actual Behaviour

In the expression tbl[x], the type of x is not checked at all

Reproduction steps

---@type table<integer, string> -- or string[]
local IntStr = {}
---@type table<string, integer>
local StrInt = {}
IntStr[5] = "hi" -- ok
IntStr["a"] = "b" -- "a" should produce a warning
StrInt["a"] = 5 -- ok
StrInt[5] = 6 -- 5 should produce a warning

Additional Notes

Probably related to #1861

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions