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

Match values for >= etc #15199

Closed
robbla opened this issue Feb 26, 2019 · 4 comments
Closed

Match values for >= etc #15199

robbla opened this issue Feb 26, 2019 · 4 comments
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/NewFeature

Comments

@robbla
Copy link

robbla commented Feb 26, 2019

Currently Match only allows for exact matches like 3 or Gold.

Support for operators like >, <, >= etc would be great as well as the support for variables and formulas.

Added the request for this functionality following a slack mailthread.

@hasithaa
Copy link
Contributor

hasithaa commented May 2, 2019

@maheshika Can we move this issue https://github.com/ballerina-platform/ballerina-spec as this is a feature request to the language.

@maheshika maheshika transferred this issue from ballerina-platform/ballerina-lang May 2, 2019
@maheshika maheshika transferred this issue from ballerina-platform/ballerina-spec May 2, 2019
@hasithaa
Copy link
Contributor

hasithaa commented May 2, 2019

Spec supports this. My Bad. The current compiler doesn't support this. Hence Issue is moved back to Ballerina-lang.

According to the spec following should work.

match x {
  y if y is int && y > 5 => { }
}

@hasithaa hasithaa added this to New Issues in Ballerina Compiler Team Tasks via automation May 2, 2019
@hasithaa hasithaa added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label May 2, 2019
@hasithaa hasithaa moved this from New Issues to Open Issues in Ballerina Compiler Team Tasks May 3, 2019
@rdhananjaya
Copy link
Member

Current implementation do support this operation with just a tiny modification to @hasithaa s answer.

match x {
  var y if y is int && y > 5 => { }
}

Not having the var in match-stmt makes it a const pattern. Only problem is we at the moment we can't mix and match these const patterns and other match-patterns in the same match statement.

@hasithaa hasithaa moved this from Open Issues to Differed Issues in Ballerina Compiler Team Tasks Aug 2, 2019
@hasithaa hasithaa moved this from Differed to Feature Requests in Ballerina Compiler Bug triage Sep 22, 2019
@hasithaa hasithaa moved this from Feature Requests and Future Tasks to [Reviewed] Follow up in Ballerina Compiler Bug triage Oct 24, 2019
@hasithaa hasithaa moved this from [Reviewed] Follow up to Features and Tasks - Design Required in Ballerina Compiler Bug triage Jan 22, 2020
@KavinduZoysa
Copy link
Contributor

FIxed in sl-alpha.

Ballerina Compiler Bug triage automation moved this from 📐Features and Tasks - Design Required to [Done] Closed Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/NewFeature
Projects
No open projects
Development

No branches or pull requests

4 participants