Confusing expression statement | Qt Qml | Qt 6.11.1
Description: [confusing-expression-statement] Confusing expression statements.

- Qt 6.11
- Qt Qml
- QML Lint Warning and Errors
- Confusing expression statement
- Qt 6.11.1 Reference Documentation

# Confusing expression statement

This warning category is spelled `[confusing-expression-statement]` by qmllint.

## Expression statement has no obvious effect

### What happened?

You used an expression statement that has no obvious effect.

### Why is that bad?

It makes the code more difficult to read and may cause confusion. Usually, it indicates that some expression result was ignored.

The expression statement is compiled into bytecode and evaluated at runtime, despite not having any effect.

### Example

     import QtQuick

     Item {
         function add(a: int, b: int) : int {
             a + b
         }
     }

To fix this warning, remove the expression without effect or use the expression result.

     import QtQuick

     Item {
         function add(a: int, b: int) : int {
             return a + b
         }
     }