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:
Christian Stenger
2021-11-05 14:49:51 +01:00
parent 0830e50185
commit f686bce68f
2 changed files with 12 additions and 10 deletions

View File

@@ -1275,6 +1275,9 @@ static bool isIntegerValue(const Value *value)
static bool strictCompareConstant(const Value *lhs, const Value *rhs) 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()) if (lhs->asUnknownValue() || rhs->asUnknownValue())
return false; return false;
if (lhs->asFunctionValue() || rhs->asFunctionValue()) // function evaluation not implemented if (lhs->asFunctionValue() || rhs->asFunctionValue()) // function evaluation not implemented
@@ -1283,12 +1286,11 @@ static bool strictCompareConstant(const Value *lhs, const Value *rhs)
return false; return false;
if (lhs->asBooleanValue() && !rhs->asBooleanValue()) if (lhs->asBooleanValue() && !rhs->asBooleanValue())
return true; return true;
// attached properties and working at runtime cases may be undefined at evaluation time if (lhs->asNumberValue() && !rhs->asNumberValue())
if (lhs->asNumberValue() && (!rhs->asNumberValue() && !rhs->asUndefinedValue()))
return true; return true;
if (lhs->asStringValue() && !rhs->asStringValue()) if (lhs->asStringValue() && !rhs->asStringValue())
return true; return true;
if (lhs->asObjectValue() && (!rhs->asObjectValue() || !rhs->asNullValue() || !rhs->asUndefinedValue())) if (lhs->asObjectValue() && (!rhs->asObjectValue() || !rhs->asNullValue()))
return true; return true;
return false; return false;
} }

View File

@@ -71,14 +71,14 @@ Rectangle {
if (s === s) {} if (s === s) {}
if (s === n) {} // 325 15 17 if (s === n) {} // 325 15 17
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 === b) {} // 325 15 17
if (s === o) {} // 325 15 17 if (s === o) {} // 325 15 17
if (s === k) {} if (s === k) {}
if (s !== s) {} if (s !== s) {}
if (s !== n) {} // 325 15 17 if (s !== n) {} // 325 15 17
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 !== b) {} // 325 15 17
if (s !== o) {} // 325 15 17 if (s !== o) {} // 325 15 17
if (s !== k) {} if (s !== k) {}
@@ -100,19 +100,19 @@ Rectangle {
if (N === o) {} // 325 15 17 if (N === o) {} // 325 15 17
if (N === k) {} if (N === k) {}
if (u === s) {} // 325 15 17 if (u === s) {}
if (u === n) {} if (u === n) {}
if (u === N) {} if (u === N) {}
if (u === u) {} if (u === u) {}
if (u === b) {} // 325 15 17 if (u === b) {}
if (u === o) {} // 325 15 17 if (u === o) {}
if (u === k) {} if (u === k) {}
if (b === s) {} // 325 15 17 if (b === s) {} // 325 15 17
if (b === n) {} // 325 15 17 if (b === n) {} // 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 === b) {}
if (b === o) {} // 325 15 17 if (b === o) {} // 325 15 17
if (b === k) {} if (b === k) {}
@@ -120,7 +120,7 @@ Rectangle {
if (o === s) {} // 325 15 17 if (o === s) {} // 325 15 17
if (o === n) {} // 325 15 17 if (o === n) {} // 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 === b) {} // 325 15 17
if (o === o) {} // 325 15 17 if (o === o) {} // 325 15 17
if (o === k) {} if (o === k) {}