You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at this code, the variable local bb should be of type fun(x: number, y: number).
the variable local aa should be of type number.
`---@Class Person
---@field age? number
---@field foo? fun(x: number, y: number)
---@param person Person
local function test(person)
if (person.age ~= nil) then
local aa = person.age -- type is number?
end
if (person.foo ~= nil) then
local bb= person.foo -- type is unknown
end
end
`
Actual Behaviour
the variable local aa be of type number?
the variable local bb be of type unknown
Reproduction steps
Go to '...'
Click '...'
See error '...'
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered:
5c3086acd08765f9122ed5b7f806e2b2bf3737e3 is the first bad commit
commit 5c3086acd08765f9122ed5b7f806e2b2bf3737e3 (HEAD)
Author: Lewis Russell <[email protected]>
Date: Sun Sep 22 17:19:12 2024 +0100
feat: type narrow types with literal fields
changelog.md | 1 +
script/vm/tracer.lua | 59 ++++++++++++++++++++++++++++++++++++++++++
test/type_inference/common.lua | 50 +++++++++++++++++++++++++++++++++++
3 files changed, 110 insertions(+)
Some observation: by flipping the ~= with ==, the function type appears again:
---@classPerson---@fieldage? number---@fieldfoofun(x: number, y: number)---@parampersonPersonlocalfunctiontest(person)
if (person.age~=nil) thenlocalaa=person.age-- type is number?endif (person.foo==nil) then--< flip this to `==`localbb=person.foo--> fun(x: number, y: number)endend
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
Looking at this code, the variable local bb should be of type fun(x: number, y: number).
the variable local aa should be of type number.
`---@Class Person
---@field age? number
---@field foo? fun(x: number, y: number)
---@param person Person
local function test(person)
if (person.age ~= nil) then
local aa = person.age -- type is number?
end
if (person.foo ~= nil) then
local bb= person.foo -- type is unknown
end
end
`
Actual Behaviour
the variable local aa be of type number?
the variable local bb be of type unknown
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: