Fix #157
This commit is contained in:
parent
df92a4d722
commit
65d2f29082
|
@ -11,7 +11,8 @@ import stdx.d.lexer;
|
||||||
import analysis.base;
|
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
|
class ObjectConstCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
|
@ -35,7 +36,7 @@ class ObjectConstCheck : BaseAnalyzer
|
||||||
&& !hasConst(d.functionDeclaration.memberFunctionAttributes)))
|
&& !hasConst(d.functionDeclaration.memberFunctionAttributes)))
|
||||||
{
|
{
|
||||||
addErrorMessage(d.functionDeclaration.name.line,
|
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");
|
~ " and toString should be declared const");
|
||||||
}
|
}
|
||||||
d.accept(this);
|
d.accept(this);
|
||||||
|
@ -51,7 +52,9 @@ class ObjectConstCheck : BaseAnalyzer
|
||||||
private static bool hasConst(const MemberFunctionAttribute[] attributes)
|
private static bool hasConst(const MemberFunctionAttribute[] attributes)
|
||||||
{
|
{
|
||||||
import std.algorithm;
|
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)
|
private static bool isInteresting(string name)
|
||||||
|
|
Loading…
Reference in New Issue