Skip to content

missing-fields diagnostic doesn't check for fields of inherited classes #2966

Closed
@SereneRuby12

Description

@SereneRuby12

How are you using the lua-language-server?

Other

Which OS are you using?

Windows

What is the issue affecting?

Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

Initializing a class instance warns of missing fields from the inherited classes.

Actual Behaviour

Initializing a class instance only checks that the fields defined in the class are present, fields inherited from other classes aren't checked, so if one of them is missing, there's no warning.

Reproduction steps

---@class A
---@field a integer

---@class B: A
---@field b integer

---@type B
local b1 = { a = 1 } -- Missing required fields in type `B`: `b`
---@type B
local b2 = { b = 2 } -- No warning shown

---@param b B
local function func_b(b)
  return b
end

func_b({ a = 1 }) -- Missing required fields in type `B`: `b`
func_b({ b = 2 }) -- No warning shown

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions