# Unreachable code?

**URL:** <https://discuss.kotlinlang.org/t/unreachable-code/813>\
**Category:** Uncategorized\
**Created:** [May 21, 2013, 2:48am UTC](https://discuss.kotlinlang.org/t/unreachable-code/813 "2013-05-21T02:48:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freewind](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/freewind/32/1479_2.png) [@freewind](https://discuss.kotlinlang.org/u/freewind)\
**Post date:** [May 21, 2013, 2:48am UTC](https://discuss.kotlinlang.org/t/unreachable-code/813/1 "2013-05-21T02:48:35Z")

</div>

Kotlin code:

``

```kotlin
package controllers
native trait Todo {
  fun deleteRecord() = noImpl   // no return type here
  fun get(key: String): Commit = noImpl
}
native trait Commit {
  fun commit()
}
native(“Ember.Controller”) trait EmberController {
  fun set(key: String, value: Any) = noImpl
  fun get(key: String): Any = noImpl
}
class TodoController: EmberController {
  var isEditing: Boolean = false
  fun editTodo() {
  this.set(“isEditing”, true)
  }
  fun removeTodo () {
  var todo = this.get(“model”) as Todo
  todo.deleteRecord()
  todo.get(“store”).commit()  // !!! can’t compiled, error: Unreachable code
  }
}

```

I don’t know why it reports “Unreachable code”.

If I change:

``

```kotlin
fun deleteRecord() = noImpl 
```

to

```kotlin
fun deleteRecord():Any = noImpl

```

It will be OK

Is it a bug ?

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [May 21, 2013, 6:22am UTC](https://discuss.kotlinlang.org/t/unreachable-code/813/2 "2013-05-21T06:22:53Z")

</div>

It is not a bug. noImpl is guaranteed to throw an exception, and its precise type (Nothing) reflects this fact. Unless you remove this type information by making the type Any, the compiler thinks that noImpl will be called and reports unreachable code.
