lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Function definition into a nested table is not handled properly

Open carsakiller opened this issue 3 years ago • 0 comments

I have run into an interesting issue while documenting Busted and luassert.

When defining a function that lives inside some nested table, I am not receiving completions in another file.

Here is a minimal example:

---@class myClass
local myClass = { has = { nested = {} } }

---Nested Function
---@param arg string
---@return boolean rtrn
function myClass.has.nested.fn(arg) end

In that same file, I receive completions for:

myClass.has.nested.fn(arg)

However, in another file, I do not… with completions ending at the below:

---@type myClass
local e = {}

e.has.nested.

Even more interestingly, defining myClass as the below, makes completion start working again in other files.

---@class myClass
local myClass = {
    has = {
        nested = {
            ---@param arg string
            ---@return boolean
            fn = function(arg) end
        }
    }
}

This only appears to be a problem when defining a function using the full function name() end syntax, and does not occur when defining it in the table literal.

carsakiller avatar Sep 17 '22 23:09 carsakiller