Skip to content

Function definition into a nested table is not handled properly #1561

Closed
@carsakiller

Description

@carsakiller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions