- Qt 6.12
- Qt Qml
- QML Lint Warning and Errors
- Unreachable code
- Qt 6.12.0 Reference Documentation

# Unreachable code

This warning category is spelled `[unreachable-code]` by qmllint.

## Unreachable code

### What happened?

Instructions in your code are unreachable and will never be executed.

### Why is that bad?

Unreachable code does not contribute to the program logic and bloats the disk and memory footprint of the application. Unreachable code can be a sign of underlying bugs or logic errors.

### Example

     function f(b: bool) : string {
         if (b)
             return "true"
         else
             return "false"
         return "something else??" // unreachable statement
     }

To fix this warning, remove the dead instructions or refactor your code to make all logic reachable.

     function f(b: bool) : string {
         if (b)
             return "true"
         else
             return "false"
     }