Exponential type checking time of nested Tuples
See original GitHub issueThis example complies in ~16 seconds on my machine, and goes to ~32 seconds with one additional level of nesting.
object Example {
case class C[H, T](h: H, t: T)
type I = Int
val p
: C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,I]]]]]]]]]]]]]]]]]]]]]]]
= C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,1)))))))))))))))))))))))
}
This explosion only happens when both the type and the value are provided, commenting the :
line or replacing the =
line with = ???
leads to normal compilation times. For some reason things work fine when replacing C
with Tuple2
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Easy way to determine a nesting level of nested tuples, in ...
If flattened tuple has size $N$, then the depth has size of the positive quadratic root of $n(n+1)/2=N$, that is $n=(-1+\sqrt(1+8N))/2$ ...
Read more >[Haskell-cafe] Exponential complexity of type checking (Was: Type ...
In general, there are programs that take exponential time/space to type check, ... Here, if fN results in a nested tuple of size...
Read more >Python | Cumulative Nested Tuple Column Product
In this, we check for the nesting type and perform recursion. This method can give flexibility of more than 1 level nesting. Python3....
Read more >Reduce compilation time for long and nested tuples
Problem: The problem is that the code takes a long time to compile (~6 minutes on the first run and ~0.2 seconds for...
Read more >How nested functions are used in Python? - Analytics Vidhya
Let's look at examples of the benefits of nested Python functions and how to use them to encapsulate code, closures, and decorators.
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
This example now compiles in 3 seconds for me, and the compilation time does not seem to significantly increase when adding more nesting. Closing.
See also https://bugs.openjdk.java.net/browse/JDK-8055984 / https://bugs.openjdk.java.net/browse/JDK-8046685 / http://hg.openjdk.java.net/jdk9/dev/langtools/rev/3793a6706e58 for some similar problems+solutions form javac.