# Unexpected type instability with getproperty but not setproperty!

**URL:** <https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975>\
**Category:** Performance\
**Created:** [July 30, 2019, 12:50pm UTC](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975 "2019-07-30T12:50:13Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [February 3, 2021, 5:44pm UTC](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975/15 "2021-02-03T17:44:37Z")

</div>

> [@Shuhua](#):
>
> When inspecting the `getproperty` code, why do we need to wrap it in a function like `f() = MyStruct(1.0).a` above?

Because otherwise you won’t get the constant propagation needed. Without a wrapper you are just asking what the return type of calling the function with any `Symbol` is.

---

_[View the full topic](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975)._
