Skip to content

False negative: Warnings missing for table length mismatch #2980

@mamekoro

Description

@mamekoro

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

In the reproduction code below, f({0}) and f({0, 0, 0}) should issue warnings because they do not match the annotation [integer, integer], which requires a two-element table (tuple).

Actual Behaviour

There are no warnings issued for tables that have an invalid length.

I can see other warnings (e.g., for f("string")), so Neovim and other diagnostics are working correctly.
Screenshot

Reproduction steps

Open a text editor with lua-ls enabled and copy/paste this code.

---@alias Cursor [integer, integer]

---@param c Cursor
local function f(c) end

f("string")

f({ 0 })
f({ 0, 0, 0 })

Additional Notes

I tested with lua-language-server 3.9.1 and 3.13.2 and both have this problem.

Log File

I checked ~/.local/state/nvim/lsp.log since :LspInfo indicates it is the log file, but it was empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions