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

Returned Object type array isnt working #274

Closed
Maxxxel opened this issue Nov 30, 2020 · 4 comments
Closed

Returned Object type array isnt working #274

Maxxxel opened this issue Nov 30, 2020 · 4 comments
Labels
bug Something isn't working feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)

Comments

@Maxxxel
Copy link

Maxxxel commented Nov 30, 2020

---@class Object
---@field a string
---@field GetObjects function
local Object = {}

---@return Object[]
function Object:GetObjects() end

local O = Object:GetObjects()

for i = 1, #O do
    local o = O[1]
    print(o.a)
end

for key, value in pairs(Object:GetObjects()) do
    print(key, value.a)
end

Results for *.a:
https://gyazo.com/1ae1e0dbbbd626b69df6227c75e642ab
https://gyazo.com/96c947f45723f84b1f4452e07325d68a

Expected results + manual fix:

It seems like

---@return type[]

Doesent work properly.

@sumneko sumneko added the feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) label Dec 1, 2020
@sumneko
Copy link
Collaborator

sumneko commented Dec 1, 2020

Not fully supported yet.

@Maxxxel
Copy link
Author

Maxxxel commented Dec 1, 2020

@sumneko I see, thanks for the information.

@sumneko
Copy link
Collaborator

sumneko commented Dec 3, 2020

Should supported in 1.4.0

@sumneko sumneko closed this as completed Dec 3, 2020
@Maxxxel
Copy link
Author

Maxxxel commented Dec 3, 2020

@sumneko

---@class AnObject
---@field public Name string
local AnObject = {}

---@class ObjectsManager
---@field GetObjects function
---@field GetObject function
local ObjectsManager = {}

---@return AnObject[]
function ObjectsManager:GetObjects() end

---@param ID number
---@return AnObject
function ObjectsManager:GetObject(ID) end

local Objects = ObjectsManager:GetObjects()

for i = 1, #Objects do
    local Object = Objects[i]
    print(Object.Name) -- Does not work
end

local Object = ObjectsManager:GetObject(1)
print(Object.Name) -- Works

If i change Objects[i] to Objects[1] it does.

@sumneko sumneko reopened this Dec 3, 2020
@sumneko sumneko added the bug Something isn't working label Dec 3, 2020
@sumneko sumneko closed this as completed in 923fcd8 Dec 4, 2020
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)
Projects
None yet
Development

No branches or pull requests

2 participants