-
Notifications
You must be signed in to change notification settings - Fork 0
[Bug]: Valid checks don't suppress undefined-global #2
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinglanguage-serverLanguage server issuesLanguage server issues
Description
Area
Language server
What happened?
Valid checks (such as IsValid) do not correctly suppress undefined-global for the rest of that scope. The expected result is that we should be narrowing the type to be any (depends on the check) even if undefined before for the rest of that scope, since if it was actually invalid, the code scoped within the valid check would not run.
How can it be reproduced?
undefined-global diagnostic should not occur in these examples:
local function TestFunction()
if not testVar then return end
if not testVar.Field then return end -- diagnostic on testVar: undefined global variable: testVar GLuaLS(undefined-global)
print(testVar) -- diagnostic on testVar: undefined global variable: testVar GLuaLS(undefined-global)
endlocal function TestFunction2()
if not istable(testVar2) then return end -- testVar2 = any
if not testVar2.TestField then return end -- testVar2 = table but still giving undefined-global diagnostic
print(testVar2.TestField) -- testVar2 = table and field TestField = any but still giving undefined-global diagnostic
endAdditional info
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinglanguage-serverLanguage server issuesLanguage server issues