このページでは

到達不可能なコード

この警告カテゴリは、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.