Skip to content

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

Closed
@TIMONz1535

Description

@TIMONz1535

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

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