fix #575 - Dscanner should allow opCmp with no toHash

This commit is contained in:
Basile Burg 2018-04-05 10:47:14 +02:00
parent a4d84a0995
commit 6fe77da02d
1 changed files with 9 additions and 6 deletions

View File

@ -76,12 +76,6 @@ class OpEqualsWithoutToHashCheck : BaseAnalyzer
string message = "'" ~ name.text ~ "' has method 'toHash', but not 'opEquals'.";
addErrorMessage(name.line, name.column, KEY, message);
}
if (hasOpCmp && !hasOpEquals)
{
addErrorMessage(name.line, name.column, KEY,
"'" ~ name.text ~ "' has method 'opCmp', but not 'opEquals'.");
}
}
enum string KEY = "dscanner.suspicious.incomplete_operator_overloading";
@ -108,6 +102,15 @@ unittest
}
}
// AA would use default equal and default toHash
struct Bee
{
int opCmp(Bee) const
{
return true;
}
}
// Fail on class opEquals
class Rabbit // [warn]: 'Rabbit' has method 'opEquals', but not 'toHash'.
{