-
-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The type of keys used to index [] tables is not checked #2610
Comments
+1 for supporting this, it is especially annoying if you have a table that is supposed to be indexed by an enum, e.g.,
|
+1 This seems to be a very core feature that has been missing for awhile. |
+1 this would be very good!!! |
Since this has now gotten attention from @sumneko I think it's worth pointing out another very similar issue that can potentially be solved by this. That is, similar challenges with using the Currently, there is no way for "fields" on classes that are enums (or any literal, really) to actually be defined as mandatory. Or any literal, for that matter. It'll do proper type checking, but it will always work as if it was e.g. ---@class Foo
---@field [1] string
---@type Foo
x = {1} -- ✅ True negative
x = {'a'} -- ✅ True positive
x = {} -- ❌ False negative For instance, we can't actually get checking on classes with fields that are enums (as @emmericp suggests). |
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 allReproduction steps
Additional Notes
Probably related to #1861
Log File
No response
The text was updated successfully, but these errors were encountered: