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

<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:** [July 30, 2019, 1:56pm UTC](https://discourse.julialang.org/t/unexpected-type-instability-with-getproperty-but-not-setproperty/26975/10 "2019-07-30T13:56:16Z")

</div>

Constant propagation doesn’t really work with recursion. Use:

```julia
function Base.getproperty(e::Entry, s::Symbol)
    if s === :value
        getfield(e, :data)[getfield(e, :id)]
    else
        getfield(e, s)
    end
end

```

---

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