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

Diagnostics nil check is suppressed by the field value matching the parameter type #3056

Open
TIMONz1535 opened this issue Jan 26, 2025 · 0 comments

Comments

@TIMONz1535
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?

Diagnostics/Syntax Checking

Expected Behaviour

Diagnostics nil check does not depend on the field parameter value

---@class A
---@field b string

---@type A?
local a

if a.b == "string1" then end  -- Need check nil
if a.b == "string" then end  -- Need check nil

Actual Behaviour

The string value "string" suppresses the triggering of diagnostics, because of type string of field b.

Image

Reproduction steps

  1. Copy the sample code
  2. Check the diagnostics a.b == "string" when a should trigger "Need check nil"

Additional Notes

No response

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