# StackOverflow during type compilation

**URL:** https://discourse.julialang.org/t/stackoverflow-during-type-compilation/1532
**Category:** General Usage
**Created:** [January 17, 2017, 3:19am UTC](https://discourse.julialang.org/t/stackoverflow-during-type-compilation/1532 "2017-01-17T03:19:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dharasim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dharasim/32/3579_2.png) [@dharasim](https://discourse.julialang.org/u/dharasim)
#### Post date: [January 17, 2017, 3:19am UTC](https://discourse.julialang.org/t/stackoverflow-during-type-compilation/1532/1 "2017-01-17T03:19:28Z")

</div>

Hello everybody,

I just found this strange behavior for that I don’t have any explanation:

```julia
julia> type F1{T,U}
           x :: Tuple{F1{Int,U}, F1{String,U}}
       end
ERROR: StackOverflowError:

```

Does somebody maybe have an idea why julia throws an error here? These two versions, however, work well:

```julia
julia> type F2{T,U}
           x :: Tuple{F2{Int,U}, F2{Int,U}}
       end

julia> type F3{T}
           x :: Tuple{F3{Int}, F3{String}}
       end

```

Cheers,  
Daniel

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [January 18, 2017, 7:03pm UTC](https://discourse.julialang.org/t/stackoverflow-during-type-compilation/1532/2 "2017-01-18T19:03:43Z")

</div>

The stackoverflow comes from trying to instantiate the left and right hand types recursively (because they both appear in the Tuple, I think). The error isn’t very helpful, but on master the `F1` type declaration doesn’t overflow, probably thanks to:

[https://github.com/JuliaLang/julia/pull/18457](https://github.com/JuliaLang/julia/pull/18457)

However, actually creating such an object may be difficult…

---

<div class="post-metadata">

### Author: ![dharasim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dharasim/32/3579_2.png) [@dharasim](https://discourse.julialang.org/u/dharasim)
#### Post date: [January 19, 2017, 6:40pm UTC](https://discourse.julialang.org/t/stackoverflow-during-type-compilation/1532/3 "2017-01-19T18:40:34Z")

</div>

Thank you very much for your answer. I think I understand the error now.

Indeed the Creation of such an object is difficult… I was just playing around with different versions of self-referential and mutually-circular type declarations, because I’m still struggling implementing them. I find it pretty hard to deal with them in julia.
