Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
CrazyFluffyPony opened this issue Jun 29, 2022 · 2 comments
Closed
Labels
bug Something isn't working feat/type check Related to the type checking feature

Comments

@CrazyFluffyPony
Copy link

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
@sumneko sumneko added bug Something isn't working feat/type check Related to the type checking feature labels Jun 30, 2022
@sumneko
Copy link
Collaborator

sumneko commented Jun 30, 2022

Should be number|nil

@sumneko sumneko closed this as completed in ab1838e Jul 1, 2022
@CrazyFluffyPony
Copy link
Author

Thank you very much for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat/type check Related to the type checking feature
Projects
None yet
Development

No branches or pull requests

2 participants