diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp index 38595a8b363..bd5d25834ed 100644 --- a/src/libs/qmljs/qmljscheck.cpp +++ b/src/libs/qmljs/qmljscheck.cpp @@ -1275,6 +1275,9 @@ static bool isIntegerValue(const Value *value) static bool strictCompareConstant(const Value *lhs, const Value *rhs) { + // attached properties and working at runtime cases may be undefined at evaluation time + if (lhs->asUndefinedValue() || rhs->asUndefinedValue()) + return false; if (lhs->asUnknownValue() || rhs->asUnknownValue()) return false; if (lhs->asFunctionValue() || rhs->asFunctionValue()) // function evaluation not implemented @@ -1283,12 +1286,11 @@ static bool strictCompareConstant(const Value *lhs, const Value *rhs) return false; if (lhs->asBooleanValue() && !rhs->asBooleanValue()) return true; - // attached properties and working at runtime cases may be undefined at evaluation time - if (lhs->asNumberValue() && (!rhs->asNumberValue() && !rhs->asUndefinedValue())) + if (lhs->asNumberValue() && !rhs->asNumberValue()) return true; if (lhs->asStringValue() && !rhs->asStringValue()) return true; - if (lhs->asObjectValue() && (!rhs->asObjectValue() || !rhs->asNullValue() || !rhs->asUndefinedValue())) + if (lhs->asObjectValue() && (!rhs->asObjectValue() || !rhs->asNullValue())) return true; return false; } diff --git a/tests/auto/qml/codemodel/check/equality-checks.qml b/tests/auto/qml/codemodel/check/equality-checks.qml index 0a24cccce9a..1a2c1f7580b 100644 --- a/tests/auto/qml/codemodel/check/equality-checks.qml +++ b/tests/auto/qml/codemodel/check/equality-checks.qml @@ -71,14 +71,14 @@ Rectangle { if (s === s) {} if (s === n) {} // 325 15 17 if (s === N) {} // 325 15 17 - if (s === u) {} // 325 15 17 + if (s === u) {} if (s === b) {} // 325 15 17 if (s === o) {} // 325 15 17 if (s === k) {} if (s !== s) {} if (s !== n) {} // 325 15 17 if (s !== N) {} // 325 15 17 - if (s !== u) {} // 325 15 17 + if (s !== u) {} if (s !== b) {} // 325 15 17 if (s !== o) {} // 325 15 17 if (s !== k) {} @@ -100,19 +100,19 @@ Rectangle { if (N === o) {} // 325 15 17 if (N === k) {} - if (u === s) {} // 325 15 17 + if (u === s) {} if (u === n) {} if (u === N) {} if (u === u) {} - if (u === b) {} // 325 15 17 - if (u === o) {} // 325 15 17 + if (u === b) {} + if (u === o) {} if (u === k) {} if (b === s) {} // 325 15 17 if (b === n) {} // 325 15 17 if (b === N) {} // 325 15 17 - if (b === u) {} // 325 15 17 + if (b === u) {} if (b === b) {} if (b === o) {} // 325 15 17 if (b === k) {} @@ -120,7 +120,7 @@ Rectangle { if (o === s) {} // 325 15 17 if (o === n) {} // 325 15 17 if (o === N) {} // 325 15 17 - if (o === u) {} // 325 15 17 + if (o === u) {} if (o === b) {} // 325 15 17 if (o === o) {} // 325 15 17 if (o === k) {}