Nesta página

Código inacessível

Essa categoria de aviso é denominada “ [unreachable-code] ” pelo qmllint.

Código inacessível

O que aconteceu?

As instruções em seu código são inacessíveis e nunca serão executadas.

Por que isso é ruim?

Código inacessível não contribui para a lógica do programa e aumenta o espaço ocupado no disco e na memória pelo aplicativo. Código inacessível pode ser um sinal de bugs subjacentes ou erros de lógica.

Exemplo

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

Para corrigir esse aviso, remova as instruções inativas ou refatore seu código para tornar toda a lógica acessível.

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.