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

Failing to parse valid Java 21 syntax: case when statement #10278

Open
1 of 3 tasks
jaredstehler opened this issue May 24, 2024 · 0 comments
Open
1 of 3 tasks

Failing to parse valid Java 21 syntax: case when statement #10278

jaredstehler opened this issue May 24, 2024 · 0 comments
Labels
bug Something isn't working lang:java priority:high Issue requires immediate attention

Comments

@jaredstehler
Copy link

jaredstehler commented May 24, 2024

Describe the bug
The semgrep parser is failing on the following valid Java 21 syntax:

  private static String calculateColor(Integer value) {
    return switch (value) {
      case Integer i when i <= -10 -> NEGATIVE_COLOR;
      case Integer i when i >= 10 -> POSITIVE_COLOR;
      default -> NEUTRAL_COLOR;
    };
  }

with the error message:

 **Semgrep encountered the following errors:**
	- Repro.java failed to parse. Does it contain a syntax error?

Verbose:
	- Syntax error at line /var/folders/q3/kq6rb1b550d7rd_pw9p7pw7c0000gq/T/tmp-371001d04VPucUAst/workspace/sources/head/MyProject/src/main/java/Repro.java:49:
 `-10 ->` was unexpected

To Reproduce
Steps to reproduce the behavior, ideally a link to https://semgrep.dev:

https://semgrep.dev/playground/r/pKU1ven/hubspot.java-21-parse-fail-case-when

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

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

Environment
Observed with semgrep python package up to 1.74.0, and on semgrep.dev.

Use case
What will fixing this bug enable for you?

@ievans ievans added bug Something isn't working lang:java priority:high Issue requires immediate attention labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lang:java priority:high Issue requires immediate attention
Development

No branches or pull requests

2 participants