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

Could not match function definition in Go interface. #4172

Closed
3 tasks
janisz opened this issue Oct 28, 2021 · 1 comment · Fixed by #4180
Closed
3 tasks

Could not match function definition in Go interface. #4172

janisz opened this issue Oct 28, 2021 · 1 comment · Fixed by #4180

Comments

@janisz
Copy link

janisz commented Oct 28, 2021

Describe the bug
Could not match function definition in interface.

To Reproduce
https://semgrep.dev/s/Dznd

Expected behavior
Function is matched.

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
If not using semgrep.dev: are you running off docker, an official binary, a local build?

@janisz janisz changed the title Could not match function definition in interface. Could not match function definition in Go interface. Oct 28, 2021
@aryx
Copy link
Collaborator

aryx commented Oct 29, 2021

It's because the syntax for method inside interfaces is ambiguous when you allow it at the top with
other Go constructs.
For example how should we parse $FOO(...)? is it a method call or a method definition in an interface.
Right now you can disambiguate by putting the 'func' keyword before as in:
https://semgrep.dev/s/Oen2

aryx added a commit to semgrep/pfff that referenced this issue Oct 29, 2021
Disambiguate using lalr(k) hack in Parsing_hacks_go

This will help semgrep/semgrep#4172

test plan:
see related PR in semgrep
aryx added a commit that referenced this issue Oct 29, 2021
Disambiguate using lalr(k) hack in Parsing_hacks_go

This closes #4172

test plan:
test files included
aryx added a commit that referenced this issue Oct 29, 2021
* [Go] allow method interface pattern

Disambiguate using lalr(k) hack in Parsing_hacks_go

This closes #4172

test plan:
test files included

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

Successfully merging a pull request may close this issue.

2 participants