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

Prevent unreachable match arms #2490

Open
Licenser opened this issue Apr 17, 2024 · 0 comments
Open

Prevent unreachable match arms #2490

Licenser opened this issue Apr 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Licenser
Copy link
Member

Describe the problem you are trying to solve

when writing a match statement it can happen that match arms become unreachable. This is generally a mistake and should lead to an error or at least a warning.

match event of
  case 1 => "event is one"
  case 2 => "event is two"
  case 3 => "event is three"
  case 1 => "event is four" # oopsie typo!!!
...
end

or less obvious (we might not catch this!):

match event of
  case %{data ~= re|(badger )?[sS]not.*|} => "event is badger snot"
  case %{data ~= glob|snot*|} => "event is snot"
...
end

Describe the solution you'd like

test if any of the cases following a statement is a complete subset of the current case

Notes

We will not get 100% on this given how many extractors we have but it's still worth getting to 80%

@Licenser Licenser added the enhancement New feature or request label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant