FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[bug] Line continuation in Python prevents a match in some cases · Issue #2815 · ast-grep/ast-grep · GitHub

Repository navigation

[bug] Line continuation in Python prevents a match in some cases #2815

Description

Please read the FAQ for the bug you encountered.

  • I have read the existing FAQ

⏯ Playground Link

https://astgrep.com/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiY29uc29sZS5sb2coJE1BVENIKSIsInJld3JpdGUiOiJsb2dnZXIubG9nKCRNQVRDSCkiLCJzdHJpY3RuZXNzIjoic21hcnQiLCJzZWxlY3RvciI6IiIsImNvbmZpZyI6Imxhbmd1YWdlOiBweXRob25cbnJ1bGU6XG4gIHBhdHRlcm46ICRBICsgJEJcbi0tLVxubGFuZ3VhZ2U6IHB5dGhvblxucnVsZTpcbiAgcGF0dGVybjogJEEgaWYgJEIgZWxzZSAkQyIsInNvdXJjZSI6ImEgPSAxIFxcXG4gICAgKyAyXG5iID0gMSArIFxcXG4gICAgMlxuYyA9IDEgXFxcbiAgICBpZiAyIGVsc2UgM1xuZCA9IDEgaWYgXFxcbiAgICAyIGVsc2UgM1xuZSA9IDEgaWYgMiBcXFxuICAgIGVsc2UgM1xuZiA9IDEgaWYgMiBlbHNlIFxcXG4gICAgMyJ9

💻 Code

Rules:

language: python
rule:
  pattern: $A + $B
---
language: python
rule:
  pattern: $A if $B else $C

Python code:

a = 1 \
    + 2
b = 1 + \
    2
c = 1 \
    if 2 else 3
d = 1 if \
    2 else 3
e = 1 if 2 \
    else 3
f = 1 if 2 else \
    3

🙁 Actual behavior

Only the second and the last out of 6 expressions are matched.

🙂 Expected behavior

All expressions should be matched - it shouldn't matter where the line continuation is.

Additional information about the issue

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL