# Compiler recursion limit

**URL:** <https://discourse.julialang.org/t/compiler-recursion-limit/112698>\
**Category:** General Usage\
**Tags:** tuple, compilation, recursion\
**Created:** [April 8, 2024, 9:13pm UTC](https://discourse.julialang.org/t/compiler-recursion-limit/112698 "2024-04-08T21:13:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [April 9, 2024, 5:07pm UTC](https://discourse.julialang.org/t/compiler-recursion-limit/112698/6 "2024-04-09T17:07:55Z")

</div>

> [@CameronBieganek](#):
>
> I’ve written some recursive code that compiles away due to (I believe) constant propagation. However, I’m afraid that if I run the code on a larger problem I will hit a compiler recursion limit and it will no longer compile away. Does anyone have a rule of thumb for how deep your code can recurse before compiler inference gives up and infers `Any`?

The compiler [won’t stop inferring recursive types](https://discourse.julialang.org/t/julia-never-stops-compiling-for-new-recursive-vector-types/110232/19), and the inference process appears to be linear to the depth of the type currently. Which would make complete inference quadratic to the depth of the actual recursive structure: you don’t want this. You would end up with a complete copy of the tree structure inhabiting the type system, very slowly, and to no benefit.

The available solutions depend on the details of the type, but revolve around partially-parameterizing at some point in the process, or insisting on `Any`.

---

_[View the full topic](https://discourse.julialang.org/t/compiler-recursion-limit/112698)._
