forked from qt-creator/qt-creator
QmlJS: Fix more invalid M325 cases
Fixes: QTCREATORBUG-27380 Change-Id: I76d1ef3d2f2a4cc9d930a006ecb3b564efea3fbc Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
This commit is contained in:
@@ -1306,7 +1306,17 @@ static bool isStringValue(const Value *value)
|
|||||||
if (value->asStringValue())
|
if (value->asStringValue())
|
||||||
return true;
|
return true;
|
||||||
if (auto obj = value->asObjectValue())
|
if (auto obj = value->asObjectValue())
|
||||||
return obj->className() == "QString" || obj->className() == "string";
|
return obj->className() == "QString" || obj->className() == "string" || obj->className() == "String";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isBooleanValue(const Value *value)
|
||||||
|
{
|
||||||
|
if (value->asBooleanValue())
|
||||||
|
return true;
|
||||||
|
if (auto obj = value->asObjectValue())
|
||||||
|
return obj->className() == "boolean" || obj->className() == "Boolean";
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1324,6 +1334,8 @@ static bool strictCompareConstant(const Value *lhs, const Value *rhs)
|
|||||||
return false;
|
return false;
|
||||||
if (isStringValue(lhs) && isStringValue(rhs))
|
if (isStringValue(lhs) && isStringValue(rhs))
|
||||||
return false;
|
return false;
|
||||||
|
if (isBooleanValue(lhs) && isBooleanValue(rhs))
|
||||||
|
return false;
|
||||||
if (lhs->asBooleanValue() && !rhs->asBooleanValue())
|
if (lhs->asBooleanValue() && !rhs->asBooleanValue())
|
||||||
return true;
|
return true;
|
||||||
if (lhs->asNumberValue() && !rhs->asNumberValue())
|
if (lhs->asNumberValue() && !rhs->asNumberValue())
|
||||||
|
@@ -139,6 +139,12 @@ Rectangle {
|
|||||||
if (nObj === 1) {}
|
if (nObj === 1) {}
|
||||||
if (nNum === 1) {}
|
if (nNum === 1) {}
|
||||||
|
|
||||||
|
var bObj = Boolean(1 > 0);
|
||||||
|
if (bObj === b) {}
|
||||||
|
|
||||||
|
var sBool = String(b);
|
||||||
|
if (sBool === s) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
|
Reference in New Issue
Block a user