lua-language-server
                                
                                 lua-language-server copied to clipboard
                                
                                    lua-language-server copied to clipboard
                            
                            
                            
                        Accessing deeply nested variable at 'if' statemet cause type collision
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?
Type Checking
Expected Behaviour
Type checking does not breaks after accessing variable at 'if' statement.
Actual Behaviour
2nd nested variable type became '<type> | unknown' so accessing variable or function which not exists in this class does not cause warning.
Reproduction steps
---@class DemoD
---@field c integer 
local DemoD = {}
DemoD.c = 0
---@class DemoC
local DemoC = {}
DemoC.D = DemoD
---@class DemoB
local DemoB = {}
DemoB.C = DemoC
---@class DemoA
local DemoA = {}
DemoA.B = DemoB
---@class DemoRoot
DemoRoot = {}
DemoRoot.A = DemoA
local d = DemoRoot.A.B.C.D
-- if d.c > 1 then end -- if we replace 'DemoRoot.A.B.C.D' with 'd' then F is undefined in all 4 cases
if DemoRoot.A.B.C.D.c > 1 then end
DemoRoot.F() -- warning: F is undefined
DemoRoot.A.F() -- warning: F  is undefined
DemoRoot.A.B.F() -- no warning
DemoRoot.A.B.C.F() -- no warning
Additional Notes
No response
Log File
No response