Skip to content

Not Equals (~=) empty table comparison confuses typing? #2952

@PennyJim

Description

@PennyJim

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Type Checking

Expected Behaviour

It to understand the comparison is bogus and not affect the expected type of the parent table.

Actual Behaviour

It somehow makes the parent table unknown?

Reproduction steps

Very specifically the ~= does this. Change it to A.b == {} or even not A.b == {} and it works fine.
But with ~=, A becomes unknown within the condition (not even after it)

---@class A
---@field b {[C]:D}
local A

if A.b ~= {} then
	local C = A
end

Additional Notes

Comparing to a table literal should probably warn that it'll never be true (or false)

Log File

service.log

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