이 페이지에서

종료되지 않은 비어 있지 않은 case 블록

qmllint에서는 이 경고 범주를 ‘ [unterminated-case] ’로 표기합니다.

종료되지 않은 비어 있지 않은 case 블록

무슨 일이 발생했나요?

switch 문 내의 case 블록이 비어 있지 않았으나 break, return 또는 throw 문으로 종료되지 않았습니다. 또한 fallthrough를 명시하는 주석도 없었습니다.

왜 문제가 될까요?

switch 문에서 fallthrough 로직은 혼란을 주거나 간과되기 쉽습니다. 의도된 것이라면 “// fallthrough”와 같은 주석으로 명시적으로 표시해야 합니다. 의도된 것이 아니라면, 이 경고는 종료 문장이 누락되었음을 나타냅니다.

예시

switch (state) {
case Main.State.Reset:
    clearState()                    // <--- "Unterminated non-empty case block"
case Main.State.Invalid:
    asyncInitState()
    return false
case Main.State.Initializing:
    // wait for initialization to complete
    return false
case Main.State.Ready:
    res = lookup(query)
    log(res.stats)
    saveToDisk(res.data)            // <--- "Unterminated non-empty case block"
default:
    throw new InvalidStateException("Unknown state")
}

이 경고를 수정하려면 누락된 종료 문장을 추가하거나, 폴스루 로직을 허용한다는 것을 명시하는 주석을 추가하십시오:

switch (state) {
case Main.State.Reset:
    clearState()
    // fallthrough                   // <--- add fallthrough comment
case Main.State.Invalid:
    asyncInitState()
    return false
case Main.State.Initializing:
    // wait for initialization to complete
    return false
case Main.State.Ready:
    res = lookup(query)
    log(res.stats)
    saveToDisk(res.data)
    return true                     // <--- add forgotten terminating statement
default:
    throw new InvalidStateException("Unknown state")
}

© 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.