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

Missing ASI when parsing a semgrep pattern #1960

Closed
hexagonrecursion opened this issue Nov 4, 2020 · 1 comment · Fixed by #1998
Closed

Missing ASI when parsing a semgrep pattern #1960

hexagonrecursion opened this issue Nov 4, 2020 · 1 comment · Fixed by #1998
Labels
bug Something isn't working lang:javascript

Comments

@hexagonrecursion
Copy link

I am trying to match this

foo(function (r) {bar(r)})

I tried this pattern https://semgrep.dev/s/6WGK/

foo(r => {bar(r)})

Got:
Pattern could not be parsed as a Javascript semgrep pattern
Run with docker image: 0.29.0

I did find a pattern that works, but I don't understand why the first one did not.

https://semgrep.dev/s/olPX/

foo(r => {bar(r);})
@mschwager mschwager added the bug Something isn't working label Nov 9, 2020
@mschwager
Copy link
Contributor

Hi @hexagonrecursion,

Thanks for the report. It looks like Semgrep unnecessarily requires a ;. This looks like a JS parsing bug to me, I'll move this to the correct board and notify the appropriate team.

@aryx aryx changed the title Error when parsing statements inside function expressions in patterns Missing ASI when parsing a semgrep pattern Nov 10, 2020
aryx added a commit to semgrep/pfff that referenced this issue Nov 10, 2020
This does the same error-recovery and ASI at error-recovery that
we do when parsing code for parsing the pattern.

This will help semgrep/semgrep#1960

test plan:
see related PR in semgrep
aryx added a commit that referenced this issue Nov 10, 2020
This does the same error-recovery and ASI at error-recovery that
we do when parsing code for parsing the pattern.

Fixes #1960

test plan:
test file included
also
$ /home/pad/semgrep/_build/default/cli/Main.exe -lang js -dump_pattern misc_asi_pattern.sgrep
does not return a parse error anymore
aryx added a commit that referenced this issue Nov 10, 2020
#1998)

This does the same error-recovery and ASI at error-recovery that
we do when parsing code for parsing the pattern.

Fixes #1960

test plan:
test file included
also
$ /home/pad/semgrep/_build/default/cli/Main.exe -lang js -dump_pattern misc_asi_pattern.sgrep
does not return a parse error anymore
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:javascript
Development

Successfully merging a pull request may close this issue.

3 participants