semgrep / semgrep

Lightweight static analysis for many languages. Find bug variants with patterns that look like source code.

Home Page:https://semgrep.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax error while using as patterns in match statements [python]

giuseppelillo opened this issue · comments

Describe the bug
as patterns within a case block causes the subject_expr of a match statement to not be parsed correctly.

Example:

match subject:
    case Clazz() as capture:
        ...

Error:

Syntax error at line target.py:12:
 `subject` was unexpected Engine(ParseError)

To Reproduce
https://semgrep.dev/playground/s/OrzAp

Expected behavior
Expression should be parsed correctly and should not give an error.

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

Use case
Fixing this bug allows for using all the features of Python match statements