Skip to content

field function bug #3089

Closed
Closed
@iamhaiwen

Description

@iamhaiwen

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

  1. Go to '...'
  2. Click '...'
  3. See error '...'

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions