# Type instability using interpolation as field of struct

**URL:** <https://discourse.julialang.org/t/type-instability-using-interpolation-as-field-of-struct/27002>\
**Category:** General Usage\
**Created:** [July 30, 2019, 10:37pm UTC](https://discourse.julialang.org/t/type-instability-using-interpolation-as-field-of-struct/27002 "2019-07-30T22:37:40Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![jbmuir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbmuir/32/4798_2.png) [@jbmuir](https://discourse.julialang.org/u/jbmuir)\
**Post date:** [July 30, 2019, 11:54pm UTC](https://discourse.julialang.org/t/type-instability-using-interpolation-as-field-of-struct/27002/5 "2019-07-30T23:54:25Z")

</div>

Ok, that is useful to know. In this case, the constructor is also doing the extra work of doing the interpolation. The thing that confuses me is that if I do `@code_warntype m.itp(x)`, that is fine, but `f(m,x)` is not even when the type information is present in `m`; I think this is quite similar to the question from [Type instability if function inside a struct is run inside another function](https://discourse.julialang.org/t/type-instability-if-function-inside-a-struct-is-run-inside-another-function/12789) , and my original solution was an attempt to emulate the accepted solution from that question

---

_[View the full topic](https://discourse.julialang.org/t/type-instability-using-interpolation-as-field-of-struct/27002)._
