forked from qt-creator/qt-creator
QmlJS: Soften strict equality check Pt II
Disable strict equality check for undefined values as there are too many ways the code model just assumes "undefined" as the information would be present at runtime only or to avoid too complex evaluation. Task-number: QTCREATORBUG-25917 Change-Id: I7c6da04f52ba767c4ef5c21078dc14ac4de86687 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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) {}
|
||||
|
Reference in New Issue
Block a user