Skip to content

Invalid type diagnostic doesn't show when passing value from array directly to a functionΒ #1643

@Jummit

Description

@Jummit

How are you using the lua-language-server?

Other

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

When using a value from an array as a parameter I expect type checking to work.

Actual Behaviour

Type checking only works when I assign the value from the array to a temporary variable, not when passing it to a function directly.

Reproduction steps

This doesn't show a warning:

---@param num integer
function receive(num)
end

---@type (integer?)[]
local values = {}

receive(values[1])

This works:

local value = values[1]
receive(value) -- Cannot assign `integer?` to parameter `integer`.

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions