-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Not Equals (~=) empty table comparison confuses typing? #2952
Comments
I checked out an older stable version
So this issue is probably introduced in #2864 by @lewis6991 🤔 |
Btw there can be cases that comparing to a table literal returns local mt = {
__eq = function (t, a, b)
return true
end
}
local t = setmetatable({}, mt)
print(t == {}) --> true For example someone may want to implement a |
Oh I thought I remember reading that compare functions don't get triggered if they don't share a metatable. Might be specific compare functions... It's been a while since I dived deep into metatables. Combined with how melty they made my brain at times? I would not be surprised if I forget fundamental things about them. |
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 toA.b == {}
or evennot A.b == {}
and it works fine.But with
~=
, A becomes unknown within the condition (not even after it)Additional Notes
Comparing to a table literal should probably warn that it'll never be true (or false)
Log File
service.log
The text was updated successfully, but these errors were encountered: