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

scala: Cannot write a pattern to match every try-catch #7807

Closed
3 tasks
IagoAbal opened this issue May 16, 2023 · 0 comments · Fixed by #7815
Closed
3 tasks

scala: Cannot write a pattern to match every try-catch #7807

IagoAbal opened this issue May 16, 2023 · 0 comments · Fixed by #7815
Labels
feature:matching lang:scala user:internal requested only by someone within Semgrep Inc.

Comments

@IagoAbal
Copy link
Collaborator

The pattern I tried to write at first doesn't work: https://semgrep.dev/s/E24L

This works https://semgrep.dev/s/7Rve but it's not very flexible, it doesn't allow you to match every try-catch.

What is the priority of the bug to you?

  • P0: blocking your adoption of Semgrep or workflow
  • P1: important to fix or quite annoying
  • P2: regular bug that should get fixed
@IagoAbal IagoAbal added user:internal requested only by someone within Semgrep Inc. feature:matching lang:scala labels May 16, 2023
@IagoAbal IagoAbal changed the title scala: Not trivial to write a pattern to match a try-catch scala: Cannot write a pattern to match every try-catch May 16, 2023
brandonspark added a commit that referenced this issue May 18, 2023
## What:
This PR makes it so you can put an ellipsis inside of a `catch { }`, as
a valid pattern.

## Why:
This makes it so you can now write a pattern which matches every kind of
`try-catch`, which SR would like to do.

## How:
Just translated a `catch { ... }` into a catch clause with an ellipsis
pattern and ellipsis body, which matches everything.

## Test plan:
`make test`


Closes #7807 

PR checklist:

- [X] Purpose of the code is [evident to future
readers](https://semgrep.dev/docs/contributing/contributing-code/#explaining-code)
- [X] Tests included or PR comment includes a reproducible test plan
- [X] Documentation is up-to-date
- [X] A changelog entry was [added to
changelog.d](https://semgrep.dev/docs/contributing/contributing-code/#adding-a-changelog-entry)
for any user-facing change
- [X] Change has no security implications (otherwise, ping security
team)

If you're unsure about any of this, please see:

- [Contribution
guidelines](https://semgrep.dev/docs/contributing/contributing-code)!
- [One of the more specific guides located
here](https://semgrep.dev/docs/contributing/contributing/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:matching lang:scala user:internal requested only by someone within Semgrep Inc.
Development

Successfully merging a pull request may close this issue.

1 participant