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

[Bug]: Issue in type narrow with empty else block #43532

Open
KavinduZoysa opened this issue Oct 29, 2024 · 0 comments
Open

[Bug]: Issue in type narrow with empty else block #43532

KavinduZoysa opened this issue Oct 29, 2024 · 0 comments
Labels

Comments

@KavinduZoysa
Copy link
Contributor

Description

function foo() returns int|string {
        int|error? i = 2;
        if i is error {
            return "";
        }
        else {} // Note this

        if i is () {
            return 2;
        }

        return i; // incompatible types: expected '(int|string)', found '(int|error)'
    }

Here we are getting wrong behaviour.

Steps to Reproduce

No response

Affected Version(s)

2201.10.2

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@KavinduZoysa KavinduZoysa added Type/Bug Lang/TypeNarrowing Issue related to type narrowing and Inferring labels Oct 29, 2024
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Oct 29, 2024
@MaryamZi MaryamZi removed the needTriage The issue has to be inspected and labeled manually label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants