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 in ImportSuggestions#distinctRefs

See original GitHub issue

Scala version: 3.0.0 CATS library: 2.6.1 JDK: Azul Zulu 11.0.11 SBT: 1.5.4

Compile under Maven, it throws the following exception. The error message does not pinpoint a specific source file that caused the issue so I can’t be more specific than this.

[ERROR] ## Exception when compiling 54 sources to /home/chris/IdeaProjects/CatsTest3/target/classes
java.lang.StackOverflowError
scala.collection.StrictOptimizedLinearSeqOps.loop$3(LinearSeq.scala:266)
scala.collection.StrictOptimizedLinearSeqOps.dropWhile(LinearSeq.scala:268)
scala.collection.StrictOptimizedLinearSeqOps.dropWhile$(LinearSeq.scala:264)
scala.collection.immutable.List.dropWhile(List.scala:79)
dotty.tools.dotc.typer.ImportSuggestions.distinctRefs(ImportSuggestions.scala:275)
dotty.tools.dotc.typer.ImportSuggestions.distinctRefs$(ImportSuggestions.scala:23)
dotty.tools.dotc.typer.Typer.distinctRefs(Typer.scala:103)
dotty.tools.dotc.typer.ImportSuggestions.distinctRefs(ImportSuggestions.scala:275)
dotty.tools.dotc.typer.ImportSuggestions.distinctRefs$(ImportSuggestions.scala:23)
dotty.tools.dotc.typer.Typer.distinctRefs(Typer.scala:103)
... last stack frame above repeated many times ...
...

When compile under sbt, it reports a number of errors. The last of which is the following. Then the console hangs at compile incremental with the timer keeps ticking:

[error] 457 | } yield passwordOk
[error] | ^
[error] |Could not find an instance of FlatMap for cats.Id.
[error] |I found:
[error] |
[error] | cats.Invariant.catsStdCommutativeMonadForTuple11[A0, A1, A2, A3, A4, A5, A6, A7
[error] | ,
[error] | A8, A9]
[error] |
[error] |But method catsStdCommutativeMonadForTuple11 in trait NTupleMonadInstances1 does not match type cats.FlatMap[cats.Id].
[error] -- [E008] Not Found Error: xxx.scala:48:25
[error] 48 | import scala.reflect.runtime.universe
[error] | ^^^^^^^^^^^^^^^^^^^^^
[error] | value runtime is not a member of reflect

| => root / Compile / compileIncremental 457s

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
smartercommented, Aug 2, 2021

Regardless of whether we can reproduce, I think it wouldn’t be a bad idea to rewrite distinctRefs to be stack-safe (e.g., as a while loop accumulating into a ListBuffer).

0reactions
chrislaileecommented, Sep 13, 2021

Possible regression with version 3.0.2. The stack overflow issue comes back when compiling with 3.0.2. The issue went away when compiled with 3.0.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import and use different packages of the same name
The code above gives two different names to the imported packages with the same name. So, there are now two different identifiers that...
Read more >
Why hooks are the best thing to happen to React
This article will explain what hooks are, what makes them unique, and why they are the best thing to happen to React.
Read more >
48 answers on StackOverflow to the most popular Angular ...
I gathered the most common questions and answers from Stackoverflow. These questions were chosen by the highest score received.
Read more >
Cross-referencing between different files - TeX
tex I have \label{a} and I want to access this in file chapterII.tex using something like \ref{a} . How to do this exactly...
Read more >
Import arbitrary code from Stack Overflow as Python modules.
Do you ever feel like all you're doing is copy/pasting from Stack Overflow? Let's take it one step further. ... code, it checks...
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