lua-language-server
lua-language-server copied to clipboard
Something not okay with enum types
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
---@enum EnumAB
local e = {
A = 0,
B = 1,
}
---@type EnumAB
local a = 1
---@type EnumAB.A
local ea = e.A
---@type EnumAB.B
local eb = e.B
---@type EnumAB.B
local eb = e.A -- Cannot assign `EnumAB.A` to `EnumAB.B`
---@type EnumAB
local ee = eb
---@type EnumAB.A
local eea = ee -- Cannot assign `EnumAB` to `EnumAB.A`
Actual Behaviour
---@enum EnumAB
local e = {
A = 0,
B = 1,
}
---@type EnumAB
local a = 1
---@type EnumAB.A
local ea = e.A -- Cannot assign `integer` to `EnumAB.A`
---@type EnumAB.B
local eb = e.B -- Cannot assign `integer` to `EnumAB.B`
---@type EnumAB.B
local eb = e.A -- Cannot assign `EnumAB.A` to `EnumAB.B`
---@type EnumAB
local ee = eb -- Cannot assign `EnumAB.B` to `EnumAB`.
---@type EnumAB.A
local eea = ee -- Cannot assign `EnumAB` to `EnumAB.A`
Reproduction steps
Additional Notes
EnumAB.A
is most likely an unintended side effect, but having restrictions inside the enum seems like a good idea
Log File
No response
exactly my thoughts :| its not as useful if you can just make a typo / change values and not be warned about it