Skip to content
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

pairs ignores table<KEY_TYPE, VALUE_TYPE> and a and b are tagged any #493

Closed
sumneko opened this issue Apr 6, 2021 · 5 comments
Closed
Labels
bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) priority.normal A normal priority topic

Comments

@sumneko
Copy link
Collaborator

sumneko commented Apr 6, 2021

for a, b in pairs(t) also ignores table<KEY_TYPE, VALUE_TYPE> and a and b are tagged any instead of KEY_TYPE and VALUE_TYPE. (Just too lazy to open another issue.)

Originally posted by @ImpleLee in #483 (comment)

@sumneko
Copy link
Collaborator Author

sumneko commented Apr 6, 2021

I cannot reproduce that, please show me a sample

@sumneko sumneko added the Info Needed More information is required label Apr 6, 2021
@ImpleLee
Copy link

ImpleLee commented Apr 7, 2021

Seems like it only happens when the type is aliased to a table type.
(Tested on version 1.20.3.)

Correct behavior when

---@type table<number, string>
a = {}
for x, y in pairs(a) do
end

x and y are correctly tagged with number and string respectively.

Wrong behavior when

---@alias t table<number, string>
---@type t
a = {}
for x, y in pairs(a) do
end

x and y are both tagged with any, while a is tagged with table<number, string> correctly.

@ImpleLee
Copy link

ping?

@sumneko
Copy link
Collaborator Author

sumneko commented Apr 13, 2021

I can reproduce now, thank you

@sumneko sumneko added bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) and removed Info Needed More information is required labels Apr 13, 2021
@disco0
Copy link

disco0 commented Apr 20, 2021

As a temporary solution you can explicit annotations for each variable (side note, block comment annotation would be great for this):

image

@sumneko sumneko added the priority.normal A normal priority topic label Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) priority.normal A normal priority topic
Projects
None yet
Development

No branches or pull requests

3 participants