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

Clarification on unreachable panic statement #1292

Open
mindula opened this issue Mar 7, 2024 · 0 comments
Open

Clarification on unreachable panic statement #1292

mindula opened this issue Mar 7, 2024 · 0 comments
Assignees
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design

Comments

@mindula
Copy link

mindula commented Mar 7, 2024

Description:

Consider the below scenario, where there's an unreachable panic error("") statement followed by a variable assignment. Shouldn't we suggest the unreachable code error for the panic statement? Currently, if there's another statement, such as a variable assignment, after the panic statement, we are suggesting the unreachable code error for the variable assignment.

Screenshot 2024-03-07 at 11 12 11

The spec says,

It is a compile error if a statement other than a panic-stmt is not reachable.

Is there a reason for not suggesting the unreachable code error for panic statements?

Suggested Labels:

Code sample that shows issue:

function test() returns error? {
    from var item in 1 ... 5
    where true
    do {
        if true {
            return;
        }
        panic error("Panic!");
        int _ = 2;
    };
}

Related Issues: ballerina-platform/ballerina-lang#42105

@anupama-pathirage anupama-pathirage added Type/Improvement Enhancement to language design Area/Lang Relates to the Ballerina language specification labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Lang Relates to the Ballerina language specification Type/Improvement Enhancement to language design
Projects
None yet
Development

No branches or pull requests

3 participants