Sur cette page

Code inaccessible

Cette catégorie d'avertissement est orthographiée « [unreachable-code] » par qmllint.

Code inaccessible

Que s'est-il passé ?

Certaines instructions de votre code sont inaccessibles et ne seront jamais exécutées.

Pourquoi est-ce un problème ?

Le code inaccessible ne contribue pas à la logique du programme et alourdit l'empreinte de l'application sur le disque et en mémoire. Le code inaccessible peut être le signe de bogues sous-jacents ou d'erreurs de logique.

Exemple

function f(b: bool) : string {
    if (b)
        return "true"
    else
        return "false"
    return "something else??" // unreachable statement
}

Pour corriger cet avertissement, supprimez les instructions inutiles ou refactorisez votre code afin de rendre toute la logique accessible.

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.