不可执行的代码
qmllint 将此警告类别拼写为“[unreachable-code] ”。
无法执行的代码
发生了什么?
代码中的指令无法被执行,因此永远不会被执行。
这有什么问题?
不可执行代码对程序逻辑毫无贡献,且会增加应用程序的磁盘和内存占用。不可执行代码可能是潜在缺陷或逻辑错误的征兆。
示例
function f(b: bool) : string {
if (b)
return "true"
else
return "false"
return "something else??" // unreachable statement
}要解决此警告,请删除这些死指令,或重构代码以确保所有逻辑都能被执行到。
function f(b: bool) : string {
if (b)
return "true"
else
return "false"
}© 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.