令人困惑的表达式语句
qmllint 将此警告类别拼写为[confusing-expression-statement] 。
表达式语句没有明显效果
发生了什么?
您使用了一个没有明显效果的表达式语句。
这有什么问题?
这会增加代码的可读性难度,并可能造成混淆。通常,这表明某些表达式的结果被忽略了。
尽管该表达式语句没有任何效果,但它仍会被编译成字节码并在运行时进行求值。
示例
import QtQuick
Item {
function add(a: int, b: int) : int {
a + b
}
}要解决此警告,请删除该无实际效果的表达式,或利用该表达式的结果。
import QtQuick
Item {
function add(a: int, b: int) : int {
return a + b
}
}© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.