无法访问的代码
此警告类别由 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.