# Type instability in nested quadgk calls

**URL:** https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667
**Category:** Performance
**Tags:** type-stability, quadgk
**Created:** [March 7, 2025, 8:59am UTC](https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667 "2025-03-07T08:59:54Z")
**Posts on this page:** 1
**Showing post:** 21

<div class="post-metadata">

### Author: ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)
#### Post date: [March 9, 2025, 6:49pm UTC](https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667/21 "2025-03-09T18:49:52Z")

</div>

My hypothesis is that the inference failure ultimately traces back to [problem with the unreliable approximation of `Core.Compiler.return_type` · Issue #35800 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/35800). There are several other github issues that are ultimately examples of this, most of them encoutering the issue due to broadcasting. Examples:

- [Function redefinition can improve performance/inlining/inference · Issue #32552 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/32552)
- [Mysterious inference failure that can be solved by redefining function · Issue #35537 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/35537)
- [Typeinference depends on execution order but should not · Issue #45388 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/45388)
- [@code\_warntype shows the following code is type unstable · Issue #49970 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/49970)
- maybe [Non-deterministic inference results? · Issue #50735 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/50735)

---

_[View the full topic](https://discourse.julialang.org/t/type-instability-in-nested-quadgk-calls/126667)._
