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
\ingroup qmllint-warnings-and-errors
6
7
\title Confusing expression statement
8
\brief [confusing-expression-statement] Confusing expression statements.
9
10
\qmllintwarningcategory confusing-expression-statement
11
12
\section1 Expression statement has no obvious effect
13
14
\section2 What happened?
15
You used an expression statement that has no obvious effect.
16
17
\section2 Why is that bad?
18
It makes the code more difficult to read and may cause confusion. Usually,
19
it indicates that some expression result was ignored.
20
21
The expression statement is compiled into bytecode and evaluated at runtime,
22
despite not having any effect.
23
24
\section2 Example
25
\qml
26
import QtQuick
27
28
Item {
29
function add(a: int, b: int) : int {
30
a + b
31
}
32
}
33
\endqml
34
To fix this warning, remove the expression without effect or use the
35
expression result.
36
37
\qml
38
import QtQuick
39
40
Item {
41
function add(a: int, b: int) : int {
42
return a + b
43
}
44
}
45
\endqml
46
*/
qtdeclarative
src
qml
doc
src
qmllint
confusing-expression-statement.qdoc
Generated on
for Qt by
1.16.1