fix #575 - Dscanner should allow opCmp with no toHash
This commit is contained in:
parent
a4d84a0995
commit
6fe77da02d
|
@ -76,12 +76,6 @@ class OpEqualsWithoutToHashCheck : BaseAnalyzer
|
||||||
string message = "'" ~ name.text ~ "' has method 'toHash', but not 'opEquals'.";
|
string message = "'" ~ name.text ~ "' has method 'toHash', but not 'opEquals'.";
|
||||||
addErrorMessage(name.line, name.column, KEY, message);
|
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";
|
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
|
// Fail on class opEquals
|
||||||
class Rabbit // [warn]: 'Rabbit' has method 'opEquals', but not 'toHash'.
|
class Rabbit // [warn]: 'Rabbit' has method 'opEquals', but not 'toHash'.
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue