Skip to content

判空检测异常 #1215

Description

@Whimsyduke

---@Class A
---@field b boolean

local x = 1

---comment
---@return A|nil
local function func()
if x == 1 then
return nil
end
return {}
end

local c = func()

if (c == nil) then
return c
elseif (c.b) then
return c
end

image

此时错误提示c需要判空,但实际上c 已经在前面分支判空了

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions