# Type stability with if statements on types

**URL:** <https://discourse.julialang.org/t/type-stability-with-if-statements-on-types/82618>\
**Category:** General Usage\
**Tags:** type-stability\
**Created:** [June 12, 2022, 5:33am UTC](https://discourse.julialang.org/t/type-stability-with-if-statements-on-types/82618 "2022-06-12T05:33:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tictaccat](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@tictaccat](https://discourse.julialang.org/u/tictaccat)\
**Post date:** [June 12, 2022, 5:33am UTC](https://discourse.julialang.org/t/type-stability-with-if-statements-on-types/82618/1 "2022-06-12T05:33:24Z")

</div>

I would like to implement something to the following effect:

```julia
function f(x)
   gx = g(x)
   if g(x) isa MyType
         return gx
   else
         return 0.
   end
end

```

If `g` is type stable, if `f` always type stable?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [June 12, 2022, 5:44am UTC](https://discourse.julialang.org/t/type-stability-with-if-statements-on-types/82618/2 "2022-06-12T05:44:46Z")

</div>

yes. To test, you could use `@code_warntype`
