Skip to content

Type narrowing in ternary operator not working correctly #2233

@felixhirt

Description

@felixhirt

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Type Checking

Expected Behaviour

In a ternary expression with type checking: "local a = type(x) == "something" and dosomething(x) or somethingelse(x)", the type should be narrowed for both cases

Actual Behaviour

The type is only narrowed for the first case (boolean here), in the second case it is still boolean or string
image

Reproduction steps

Copy the code

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