Skip to content

param-type-mismatch on collapsed list of string literals #3188

@cprn

Description

@cprn

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

LuaLS correctly autocompletes a string value according to annotation, then doesn't complain about it.

Actual Behaviour

LuaLS correctly autocompletes a string value according to annotation, but then claims it's of a wrong type.

Image

Happens only to values that aren't visible on the collapsed list, e.g. return, clear, a, b, c all work fine, but not escape, print, power, euro, etc.

Reproduction steps

  1. install love (or anything with a long list of constants)
  2. open example.lua (below)
  3. go to foo() call
  4. autocomplete parameter, e.g. escape

Additional Notes

-- example.lua
love = require('love')

---@param bar love.KeyConstant
function foo(bar)  -- checking `bar` type returns entire list, including "escape"
    print(bar)
end

foo('escape')  -- LuaLS correctly autocompletes "escape" here

The error happens for every value that isn't visible on a collapsed list from the screenshot, I think.

Log File

file_home_deck_tmp_test.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions