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

[Task]: Introduce tooling support for check-on-fail-expr #41084

Closed
prakanth97 opened this issue Jul 25, 2023 · 3 comments
Closed

[Task]: Introduce tooling support for check-on-fail-expr #41084

prakanth97 opened this issue Jul 25, 2023 · 3 comments
Assignees
Labels
needTriage The issue has to be inspected and labeled manually Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Task userCategory/Editor

Comments

@prakanth97
Copy link
Contributor

Description

Refer :- ballerina-platform/ballerina-spec#1197

Syntax: check E on fail x => F

Describe your task(s)

No response

Related area

-> Editor

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Editor labels Jul 25, 2023
@prakanth97
Copy link
Contributor Author

prakanth97 commented Jul 25, 2023

Below are few example use cases.
Case 1:

function returnError1() returns error? {
    return error("Something went wrong");
}

public function main() returns error? {
    check returnError1() on fail e => error("Custom error", e);
}

Case 2:

function returnInt() returns int => 3;

// Can be declared in module variable definition
int val2 = check returnInt() on fail e => error("Error occurred", e);

function testCheckedOnFailExprReturnsValue() {
    // ternary expr
    int val = check returnInt() on fail e => error("Error occurred", e) is int ? 1 : 0;
}

Case 3:
According to this ballerina-platform/ballerina-spec#1197 (comment) below case also valid.

function testCheckedOnFailExprReturnsValue() {
    int val = check returnInt() on fail e => err(e);
}

function err(error e) returns error {
    return error("Error occurred", e);
}

@prakanth97
Copy link
Contributor Author

prakanth97 commented Jul 25, 2023

With this #41079 PR compiler changes will be added

@mindula mindula self-assigned this Jul 26, 2023
@mindula mindula added the Team/LanguageServer Language Server Implementation related issues. #Compiler label Jul 26, 2023
@KavinduZoysa
Copy link
Contributor

Closing this issue because this feature is on hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Team/LanguageServer Language Server Implementation related issues. #Compiler Type/Task userCategory/Editor
Projects
Archived in project
Development

No branches or pull requests

4 participants