We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Visual Studio Code Extension (sumneko.lua)
Windows
Type Checking
expected the value type of mapping when index
got an unknown
---@enum(key) AttrName local o = { ['hp_max'] = true, } local map = { ['hp_max'] = 114514, } ---@param t table<AttrName, number> local function test(t) --[[ Usage 1: correct ]] local a = 'hp_max' local b = t[a] -- expected: number, got: number print(b) --[[ Usage 2: incorrect ]] local c = t['hp_max'] -- expected: number, got: unknown print(c) --[[ Usage 3: correct ]] local d = "hp_grow" local e = t[d] -- expected: unknown, got: unknown print(e) end test(map)
No response
The text was updated successfully, but these errors were encountered:
similar issue: #2791
And as a bonus case for the code snippet above:
--[[ Usage 4: incorrect ]] local x local y = t[x] -- expected: unknown, got: number
seems when using unknown key to index this table, it will incorrectly infer as number as well
unknown
number
Sorry, something went wrong.
No branches or pull requests
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
expected the value type of mapping when index
Actual Behaviour
got an unknown
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: