Auf dieser Seite

Nicht erreichbarer Code

Diese Warnkategorie wird von qmllint als „ [unreachable-code] “ bezeichnet.

Nicht erreichbarer Code

Was ist passiert?

Anweisungen in Ihrem Code sind nicht erreichbar und werden niemals ausgeführt.

Warum ist das schlecht?

Nicht erreichbarer Code trägt nicht zur Programmlogik bei und erhöht den Speicherplatz- und Speicherbedarf der Anwendung. Nicht erreichbarer Code kann ein Anzeichen für zugrunde liegende Fehler oder Logikfehler sein.

Beispiel

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

Um diese Warnung zu beheben, entfernen Sie die überflüssigen Anweisungen oder überarbeiten Sie Ihren Code so, dass die gesamte Logik erreichbar ist.

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.