이 페이지에서

혼동하기 쉬운 플러스 기호

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

혼동되기 쉬운 플러스 기호

무슨 일이 있었나요?

JavaScript 코드에서 '+'로 표기된 연산자들이 혼란스럽게 조합되어 사용되었습니다. 인접한 '+' 연산자들을 구별하기 어려울 수 있습니다. 비표준적인 공백 사용으로 인해 이 문제가 더욱 악화될 수 있습니다.

왜 문제가 될까요?

코드의 가독성을 떨어뜨리고 혼란을 야기할 수 있습니다.

예시

import QtQuick

Item {
    function f(a: int, b: int) {
        let x = a++ + b
        let y = a + +b
        let z = a + ++b
        return x + y + z
    }
}

이 경고를 해결하려면, 비슷한 '+' 연산자가 나란히 배치되지 않도록 코드를 수정하십시오. 가능한 경우 식을 단순화하십시오. 불필요한 단항 연산자와 공백을 제거하고, 괄호를 사용하여 부분식을 분리하십시오.

이러한 연산자가 형 변환을 수행할 수 있다는 점에 유의하십시오. b의 유형에 따라 a + +b 와 a + b 는 동등하지 않을 수 있습니다.

import QtQuick

Item {
    function f(a: int, b: int) {
        let x = (a++) + b
        let y = a + b
        let z = a + b + 1
        return x + y + z
    }
}

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