Skip to content
Snippets Groups Projects
Commit 5355c8ef authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Don't warn for "string == ''" and "boolean == true".

Reviewed-by: Roberto Raggi
parent 042ee8de
No related branches found
No related tags found
No related merge requests found
...@@ -545,13 +545,15 @@ static bool shouldAvoidNonStrictEqualityCheck(ExpressionNode *exp, const Value * ...@@ -545,13 +545,15 @@ static bool shouldAvoidNonStrictEqualityCheck(ExpressionNode *exp, const Value *
if (NumericLiteral *literal = cast<NumericLiteral *>(exp)) { if (NumericLiteral *literal = cast<NumericLiteral *>(exp)) {
if (literal->value == 0 && !other->asNumberValue()) if (literal->value == 0 && !other->asNumberValue())
return true; return true;
} else if (cast<TrueLiteral *>(exp) || cast<FalseLiteral *>(exp) || cast<NullExpression *>(exp)) { } else if ((cast<TrueLiteral *>(exp) || cast<FalseLiteral *>(exp)) && !other->asBooleanValue()) {
return true;
} else if (cast<NullExpression *>(exp)) {
return true; return true;
} else if (IdentifierExpression *ident = cast<IdentifierExpression *>(exp)) { } else if (IdentifierExpression *ident = cast<IdentifierExpression *>(exp)) {
if (ident->name && ident->name->asString() == QLatin1String("undefined")) if (ident->name && ident->name->asString() == QLatin1String("undefined"))
return true; return true;
} else if (StringLiteral *literal = cast<StringLiteral *>(exp)) { } else if (StringLiteral *literal = cast<StringLiteral *>(exp)) {
if (!literal->value || literal->value->asString().isEmpty()) if ((!literal->value || literal->value->asString().isEmpty()) && !other->asStringValue())
return true; return true;
} }
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment