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

Cannot use an error binding pattern in the on-fail-clause #29183

Closed
MaryamZi opened this issue Mar 13, 2021 · 1 comment · Fixed by #41049
Closed

Cannot use an error binding pattern in the on-fail-clause #29183

MaryamZi opened this issue Mar 13, 2021 · 1 comment · Fixed by #41049
Assignees
Labels
Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler Area/Parser Everything related to the ballerina lexer and the parser #Compiler Area/SyntaxAPI Ballerina syntax API related issues #Compiler Area/TypeChecker Type Checker related issues #Compiler Spec/Different Implementation or runtime behavior is different from the spec. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/NewFeature
Milestone

Comments

@MaryamZi
Copy link
Member

Description:
The spec defines on-fail-clause as

on-fail-clause := on fail typed-binding-pattern statement-block

But only capture binding patterns seem to be allowed atm.

Steps to reproduce:

public function main() {
    do {
        fail error("error!");
    } on fail var error(m) {

    }
}

results in compilation errors.

$ bal run foo.bal 

Compiling source
        foo.bal
ERROR [foo.bal:(4:19,4:19)] missing identifier
ERROR [foo.bal:(4:19,4:19)] missing open brace token
ERROR [foo.bal:(4:25,4:26)] undefined symbol 'm'
ERROR [foo.bal:(4:28,6:6)] incompatible types: expected 'error', found 'record {| |} & readonly'
ERROR [foo.bal:(4:28,4:28)] missing equal token
ERROR [foo.bal:(7:1,7:1)] missing semicolon token
ERROR [foo.bal:(7:2,7:2)] missing close brace token

Affected Versions:
slalpha2, slalpha3-SNAPSHOT

@MaryamZi MaryamZi added Type/Bug Type/SpecDeviation Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Mar 13, 2021
@hasithaa hasithaa added the Spec/Different Implementation or runtime behavior is different from the spec. label Mar 15, 2021
@pcnfernando pcnfernando self-assigned this Jun 3, 2021
@grainier grainier added Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler Area/TypeChecker Type Checker related issues #Compiler and removed Type/SpecDeviation labels Jun 17, 2021
@lochana-chathura lochana-chathura added Area/Parser Everything related to the ballerina lexer and the parser #Compiler Area/SyntaxAPI Ballerina syntax API related issues #Compiler labels Jan 20, 2022
@pcnfernando pcnfernando removed their assignment Jun 29, 2022
@KavinduZoysa KavinduZoysa added Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Deferred labels Mar 3, 2023
@MaryamZi MaryamZi reopened this Apr 3, 2023
@MaryamZi MaryamZi removed the Deferred label Apr 3, 2023
@MaryamZi MaryamZi moved this to Planned for Sprint in Ballerina Team Main Board Apr 3, 2023
@MaryamZi MaryamZi added Type/NewFeature and removed Type/Bug Reason/EngineeringMistake The issue occurred due to a mistake made in the past. labels Apr 3, 2023
@MaryamZi
Copy link
Member Author

MaryamZi commented Apr 4, 2023

Note that since the typed binding pattern was made optional, this is now

on-fail-clause := on fail [typed-binding-pattern] statement-block

@suleka96 suleka96 moved this from Planned for Sprint to In Progress in Ballerina Team Main Board Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CodeAnalysis Data flow , Code and Closure analysis related issues #Compiler Area/Parser Everything related to the ballerina lexer and the parser #Compiler Area/SyntaxAPI Ballerina syntax API related issues #Compiler Area/TypeChecker Type Checker related issues #Compiler Spec/Different Implementation or runtime behavior is different from the spec. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/NewFeature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants