semgrep / pfff

pfff is mainly an OCaml API to write static analysis, dynamic analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code.
https://semgrep.dev
Other
186 stars 29 forks source link

fix(scala): parse guard in generator if there is a newline #553

Closed brandonspark closed 2 years ago

brandonspark commented 2 years ago

Goes with #6033.

What: We currently fail to parse Scala programs which contain newlines before the guard of generator expressions.

Why: This breaks some use cases. For instance, we cannot parse:

for {
  x <- 3
  if b 
} yield 3

How: I just added a thing which, irregardless of if there is a newline or space, checks beyond it to see if the next token is an if. If so, then it enters the guard loop.

Test plan: make test

Security

brandonspark commented 2 years ago

Turns out the segfaults were because of an infinite loop. On another architecture, they seemed not to loop though. Kind of wild.

aryx commented 2 years ago

I'll try to look at the circleCI error tomorrow. I think I know why.