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

Add non-nestable OR patterns without bindings #805

Open
jiribenes opened this issue Jan 28, 2025 · 0 comments
Open

Add non-nestable OR patterns without bindings #805

jiribenes opened this issue Jan 28, 2025 · 0 comments
Labels
feature New feature or request requires-design

Comments

@jiribenes
Copy link
Contributor

jiribenes commented Jan 28, 2025

Support non-nestable OR patterns without bindings such as:

str match {
  "YES" | "NO" => ...
  _ => ...
}

car match {
  case Car("Mercedes-Benz", _) | Car("smart", _) => ...
  _ =>
}

people match {
  case Cons("Joe", Nil()) | Cons("Jolene", Nil()) => ...
  ...
}

only on the top-level (no nesting) and for patterns without bindings (those should be rejected).
This way, we get the 80% of use cases with 20% of the work of implementing actual nested OR patterns with bindings.

Then this change should be somewhat simple to add, just duplicating the branches.

@jiribenes jiribenes added feature New feature or request requires-design labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request requires-design
Projects
None yet
Development

No branches or pull requests

1 participant