Skip to content

upgrade from 3.6.3 to 3.6.4 broke the type detection of nested objects when @cast is used #1737

@muppet9010

Description

@muppet9010

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?

Annotations, Type Checking

Expected Behaviour

In 3.6.3 the code in Reproduction Steps has the value of x resolving to the correct type.

Actual Behaviour

In 3.6.4 this is no longer the case and gives the error:

"code": "no-unknown",
"severity": 4,
"message": "Can not infer type.",
"source": "Lua Diagnostics.",

image

Reproduction steps

---@class Container
---@field object Object

---@class Object
---@field speed number?

local object, x
local things ---@type Container[]

for _, thing in pairs(things) do
    object = thing.object
    x = object.speed ---@cast x - nil
end

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions