Skip to content

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

@sapphyrus

Description

@sapphyrus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions