Skip to content

No types or documentation hover/autocompletion for tables passed to functions #720

@grapereader

Description

@grapereader

Describe the bug

When passing a table to function with a parameter of some class type, the fields of the class are not suggested, and documentation comments are not visible.

Creating an object annotated by @type of the class works correctly.

To Reproduce

Steps to reproduce the behavior:

  1. Create a class type
  2. Create a function with a parameter of the class type
  3. Attempt to call the function, and begin defining the table

Expected behavior

Intellisense hints should show the fields of the class, and fields of child classes, along with documentation comments.

Screenshots

For types declared explicitly, works as expected

ss1
ss2

Types from function parameters, no documentation hints (also no intellisense/auto completion)

ss3
ss4

Environment

  • OS: Windows and Linux
  • Is WSL remote? Occurs in both
  • Client: VSCode

Additional context

Example code
---@class ChildTable
---@field someField integer This is an important field
local ChildTable = { }

---@class ArgsTable
---@field child ChildTable Some child arguments
---@field arg1 string Some argument
local ArgsTable = { }

---@param argsTable ArgsTable
local function someFunc(argsTable) end

---@type ArgsTable
local args = {
	arg1 = "",
	child = {
		someField = 3
	}
}

someFunc({
	arg1 = "",
	child = {
		someField = 3
	}
})
Config dump
Lua = {
        color = {
            mode = "Semantic",
        },
        completion = {
            autoRequire = true,
            callSnippet = "Disable",
            displayContext = 0,
            enable = true,
            keywordSnippet = "Replace",
            requireSeparator = ".",
            showParams = true,
            showWord = "Fallback",
            workspaceWord = true,
        },
        diagnostics = {
            disable = {
            },
            enable = true,
            globals = {
                [1] = "minetest",
                [2] = "vector",
                [3] = "dump",
                [4] = "dump2",
            },
            ignoredFiles = "Opened",
            libraryFiles = "Opened",
            neededFileStatus = {
            },
            severity = {
            },
            workspaceDelay = 0,
            workspaceRate = 100,
        },
        hint = {
            enable = true,
            paramName = "All",
            paramType = true,
            setType = true,
        },
        hover = {
            enable = true,
            enumsLimit = 5,
            previewFields = 20,
            viewNumber = true,
            viewString = true,
            viewStringMax = 1000,
        },
        misc = {
            parameters = {
            },
        },
        runtime = {
            builtin = {
            },
            fileEncoding = "utf8",
            nonstandardSymbol = {
            },
            path = {
                [1] = "?.lua",
                [2] = "?/init.lua",
            },
            plugin = "",
            special = {
            },
            unicodeName = false,
            version = "Lua 5.4",
        },
        signatureHelp = {
            enable = true,
        },
        telemetry = {
        },
        window = {
            progressBar = true,
            statusBar = true,
        },
        workspace = {
            checkThirdParty = true,
            ignoreDir = {
                [1] = ".vscode",
            },
            ignoreSubmodules = true,
            library = {
            },
            maxPreload = 1000,
            preloadFileSize = 100,
            useGitIgnore = true,
            userThirdParty = {
            },
        },
    }

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