Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative for param-type-mismatch when using a variable as argument #2734

Open
bavalpey opened this issue Jun 27, 2024 · 0 comments
Open

Comments

@bavalpey
Copy link
Contributor

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

---@class (exact) Foo
---@field FooField integer
local Foo

---@param FooParam Foo
local function test(FooParam) end

local x = {z = 1}
test(x)

test({z = 1})

In the example above, Lua LS should report a param-type-mismatch diagnostic for test(x). It has enough information to know that x cannot be of type Foo, at the very least because it is missing FooField.
We see that test({z=1}) correctly reports the param-type-mismatch diagnostic.

Actual Behaviour

No error is reported.
image

Reproduction steps

In any editor with Lua LS installed, write the provided code. Observe that there are no squiggles reported.

Additional Notes

I would say this is a pretty serious bug. I would have expected Lua LS's type checking to be robust enough to handle checking the types of variables. It seems that all it is doing is checking that the type is a table.

IS this because there is no narrowing of variables once they become tables? This is only done for table literals?

Log File

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant