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

Incorrect "Need check nil" with x or error(...) pattern #1945

Closed
sapphyrus opened this issue Feb 26, 2023 · 0 comments
Closed

Incorrect "Need check nil" with x or error(...) pattern #1945

sapphyrus opened this issue Feb 26, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@sapphyrus
Copy link

sapphyrus commented Feb 26, 2023

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I would expect no "Need check nil" diagnostic to be emitted since execution will never reach line 3 if bar is nil.

Actual Behaviour

A warning is printed

Reproduction steps

local foo = {}
local bar = foo[1] or error("Not found")
print(bar.asd) -- Need check nil.

Additional Notes

No response

Log File

No response

@sumneko sumneko added the bug Something isn't working label Mar 1, 2023
@sumneko sumneko closed this as completed in a9fe326 Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants