Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
confusing-expression-statement.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qmllint-warnings-and-errors-confusing-expression-statement.html
6\ingroup qmllint-warnings-and-errors
7
8\title Confusing expression statement
9\brief [confusing-expression-statement] Confusing expression statements.
10
11\qmllintwarningcategory confusing-expression-statement
12
13\section1 Expression statement has no obvious effect
14
15\section2 What happened?
16You used an expression statement that has no obvious effect.
17
18\section2 Why is that bad?
19It makes the code more difficult to read and may cause confusion. Usually,
20it indicates that some expression result was ignored.
21
22The expression statement is compiled into bytecode and evaluated at runtime,
23despite not having any effect.
24
25\section2 Example
26\qml
27import QtQuick
28
29Item {
30 function add(a: int, b: int) : int {
31 a + b
32 }
33}
34\endqml
35To fix this warning, remove the expression without effect or use the
36expression result.
37
38\qml
39import QtQuick
40
41Item {
42 function add(a: int, b: int) : int {
43 return a + b
44 }
45}
46\endqml
47*/