# 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:** 3

<div class="post-metadata">

**Author:** ![cshenton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cshenton/32/9326_2.png) [@cshenton](https://discourse.julialang.org/u/cshenton)\
**Post date:** [July 30, 2019, 1:12pm UTC](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975/3 "2019-07-30T13:12:31Z")

</div>

I would have expected the other branches to be eliminated since `:value` is a compile time constant, re Stefan’s comment here [How to use `getproperty`/`setproperty!`?](https://discourse.julialang.org/t/how-to-use-getproperty-setproperty/16033).

For example:

```julia
const branch = true
example() = branch ? 0.0 : 0
@code_warntype example()

```

example() “looks” type unstable, but the compiler correctly eliminates the branch and then infers the type, meaning no type instability.

```julia
Body::Float64
1 ─ return 0.0

```

I’m asking why the same isn’t happening here, since (I think) `:value` is a compile time constant.

---

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