Skip to content

return-type-mismatch does not understand and statement with functions #1256

Closed
@CrazyFluffyPony

Description

@CrazyFluffyPony

Describe the bug
I get a return-type-mismatch warning for correct lua code.

return valueA and valueB

should use the type of valueB (see below screenshot)

image

But when writing code like this (see below screenshot), it suddenly takes the type of valueA.

image

To Reproduce

---@return table|nil
function getDetail()
    return nil
end

---@return number|nil
function other()
    return nil
end

---@return number
function example()
    local detail = getDetail()

    return detail and other()
end

Expected behavior
Correct type detection.

Environment (please complete the following information):

  • OS: Windows 10
  • VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeat/type checkRelated to the type checking feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions