This commit is contained in:
Hackerpilot 2014-04-10 14:09:33 -07:00
parent df92a4d722
commit 65d2f29082
1 changed files with 6 additions and 3 deletions

View File

@ -11,7 +11,8 @@ import stdx.d.lexer;
import analysis.base;
/**
* Checks for use of the deprecated "delete" keyword
* Checks that opEquals, opCmp, toHash, and toString are either const,
* immutable, or inout.
*/
class ObjectConstCheck : BaseAnalyzer
{
@ -35,7 +36,7 @@ class ObjectConstCheck : BaseAnalyzer
&& !hasConst(d.functionDeclaration.memberFunctionAttributes)))
{
addErrorMessage(d.functionDeclaration.name.line,
d.functionDeclaration.name.column, "opCmp, ToHash, opEquals,"
d.functionDeclaration.name.column, "opCmp, toHash, opEquals,"
~ " and toString should be declared const");
}
d.accept(this);
@ -51,7 +52,9 @@ class ObjectConstCheck : BaseAnalyzer
private static bool hasConst(const MemberFunctionAttribute[] attributes)
{
import std.algorithm;
return attributes.any!(a => a.tokenType == tok!"const");
return attributes.any!(a => a.tokenType == tok!"const"
|| a.tokenType == tok!"immutable"
|| a.tokenType == tok!"inout");
}
private static bool isInteresting(string name)