Skip to content

Undefined field diagnostic broken #422

Description

@ZLOY5

Describe the bug
Undefined field diagnostic broken in some cases

To Reproduce
Open code in editor. If you uncomment ---@type annotation all works fine
I guess something wrong with types inference

---@class CEntityInstance
CEntityInstance = {}
---@class CBaseEntity:CEntityInstance
CBaseEntity = {}
---@class CBaseModelEntity:CBaseEntity
CBaseModelEntity = {}
---@class CBaseAnimating:CBaseModelEntity
CBaseAnimating = {}
---@class CBaseFlex:CBaseAnimating
CBaseFlex = {}
---@class CDOTA_BaseNPC:CBaseFlex
CDOTA_BaseNPC = {}

---@return string
function CDOTA_BaseNPC:GetUnitName() end

---@return number
function CDOTA_BaseNPC:GetHealth() end

---@return CDOTA_BaseNPC
function CreateTestUnit() end

-----@type CDOTA_BaseNPC
local unit = CreateTestUnit()
unit.testField = 3

if unit.testField then
	local test = unit.testField
end

Screenshots
image

Environment

  • OS: Windows 10
  • Client: VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions