# Is this a bug about type inference?

**URL:** <https://discuss.kotlinlang.org/t/is-this-a-bug-about-type-inference/2789>\
**Category:** Support\
**Created:** [May 23, 2017, 1:47am UTC](https://discuss.kotlinlang.org/t/is-this-a-bug-about-type-inference/2789 "2017-05-23T01:47:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kobe2000](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kobe2000](https://discuss.kotlinlang.org/u/kobe2000)\
**Post date:** [May 23, 2017, 1:47am UTC](https://discuss.kotlinlang.org/t/is-this-a-bug-about-type-inference/2789/1 "2017-05-23T01:47:09Z")

</div>

```auto
val shouldBeInt = run {
    var i = 1
    while(true) {
        if (i > 10) return@run i
    }
}

```

In above code piece, sholeBeInt would be Any type instead of Int

---

<div class="post-metadata">

**Author:** ![chimmihc](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/chimmihc/32/2013_2.png) [@chimmihc](https://discuss.kotlinlang.org/u/chimmihc)\
**Post date:** [May 23, 2017, 6:58am UTC](https://discuss.kotlinlang.org/t/is-this-a-bug-about-type-inference/2789/2 "2017-05-23T06:58:00Z")

</div>

Return an int after the while loop and it will work as expected.

There is an implicit return of `Unit`.
