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?
15You used an expression statement that has no obvious effect.
16
17\section2 Why is that bad?
18It makes the code more difficult to read and may cause confusion. Usually,
19it indicates that some expression result was ignored.
20
21The expression statement is compiled into bytecode and evaluated at runtime,
22despite not having any effect.
23
24\section2 Example
25\qml
26import QtQuick
27
28Item {
29 function add(a: int, b: int) : int {
30 a + b
31 }
32}
33\endqml
34To fix this warning, remove the expression without effect or use the
35expression result.
36
37\qml
38import QtQuick
39
40Item {
41 function add(a: int, b: int) : int {
42 return a + b
43 }
44}
45\endqml
46*/