Stack Overflow with complex expressions
See original GitHub issueWe occasionally get a StackOverflowError using ScalaStyle in our builds. The end of the stack is shown below, but I believe this is due to the fact that groupBy is implemented using recursion but not @tailrec.
Since the stack trace is cut off, I don’t actually have the sample code that generates the problem. However, I can generate the problem with the following valid (albeit unlikely) unit test. The Scala compiler handles this expression fine.
"Parser" should "handle deep complex expressions" in {
parseExpression("o.p(a" + (",a" * 2000) + ")")
}
I’m happy to submit a PR to fix this – give me a day or two to put it together. I’ll add tests for the updated groupBy (since I’m changing it) as well as the above.
The stack trace:
java.lang.StackOverflowError
at scalariform.utils.Utils$$anonfun$4.apply(Utils.scala:61)
at scalariform.utils.Utils$$anonfun$4.apply(Utils.scala:61)
at scala.collection.immutable.List.span(List.scala:369)
at scalariform.utils.Utils$.groupBy(Utils.scala:61)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
at scalariform.utils.Utils$.groupBy(Utils.scala:62)
... and groupBy all the way down.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
85. STACK OVERFLOW. EXPRESSION TOO COMPLEX.
LINGO uses a stack to store temporary values while executing the expressions in a model. The default stack size is quite large, thus...
Read more >Jekyll/Liquid complex expressions - Stack Overflow
How do do formulate in Jekyll/Liquid language the following expression: if (A and B) or (not C). What are the rules globally (precedence, ......
Read more >16.10 - 2600 Stack overflow -- expression too complicated.
2600 Stack overflow -- expression too complicated. Explanation: This error occurs because an expression employs too many levels of ...
Read more >Evaluating a complex expression
I have the function complex valued function g[z_]:=(2a z^2+bz)/(az^2+bz) where z=eiθ.I want g in terms of cos(θ) and sin(θ).
Read more >Parser stack overflow at: <token name>
The statement being compiled is too complex. It may contain a complex expression, or deeply nested block statements, such as a Do or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 for releasing this fix.
occurred in scalastyle version 1.0.0, how was this going on?