question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stack Overflow with complex expressions

See original GitHub issue

We 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
idserdacommented, Nov 20, 2018

+1 for releasing this fix.

0reactions
f7753commented, Nov 14, 2019

occurred in scalastyle version 1.0.0, how was this going on?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found