- Qt 6.10
- Qt Qml
- QML Lint Warning and Errors
- Unterminated non-empty case block
- Qt 6.10.2 Reference Documentation

# Unterminated non-empty case block

This warning category is spelled `[unterminated-case]` by qmllint.

## Unterminated non-empty case block

### What happened?

A case block in a switch statement was non-empty but was not terminated by a break, return, or throw statement. There was also no opt-in fallthrough comment.

### Why is that bad?

Fallthrough logic in switch statements can be confusing or overlooked. If it is intentional, it should be marked explicitly with a comment such as "// fallthrough". If it isn't intentional, the warning indicates that a terminating statement was forgotten.

### Example

     switch (state) {
     case Main.State.Reset:
         clearState()                    // <--- "Unterminated non-empty case block"
     case Main.State.Invalid:
         asyncInitState()
         return false
     case Main.State.Initializing:
         // wait for initialization to complete
         return false
     case Main.State.Ready:
         res = lookup(query)
         log(res.stats)
         saveToDisk(res.data)            // <--- "Unterminated non-empty case block"
     default:
         throw new InvalidStateException("Unknown state")
     }

To fix this warning, add missing terminating statements or add explicit opt-in comments allowing fallthrough logic:

     switch (state) {
     case Main.State.Reset:
         clearState()
         // fallthrough                   // <--- add fallthrough comment
     case Main.State.Invalid:
         asyncInitState()
         return false
     case Main.State.Initializing:
         // wait for initialization to complete
         return false
     case Main.State.Ready:
         res = lookup(query)
         log(res.stats)
         saveToDisk(res.data)
         return true                     // <--- add forgotten terminating statement
     default:
         throw new InvalidStateException("Unknown state")
     }