False positive on inout @property functions
This commit is contained in:
parent
16d76d8b05
commit
2b79fca42e
|
@ -63,19 +63,21 @@ class FunctionAttributeCheck : BaseAnalyzer
|
||||||
bool foundProperty = false;
|
bool foundProperty = false;
|
||||||
foreach (attribute; dec.attributes)
|
foreach (attribute; dec.attributes)
|
||||||
foundConst = foundConst || attribute.attribute.type == tok!"const"
|
foundConst = foundConst || attribute.attribute.type == tok!"const"
|
||||||
|| attribute.attribute.type == tok!"immutable";
|
|| attribute.attribute.type == tok!"immutable"
|
||||||
|
|| attribute.attribute.type == tok!"inout";
|
||||||
foreach (attribute; dec.memberFunctionAttributes)
|
foreach (attribute; dec.memberFunctionAttributes)
|
||||||
{
|
{
|
||||||
foundProperty = foundProperty || (attribute.atAttribute !is null
|
foundProperty = foundProperty || (attribute.atAttribute !is null
|
||||||
&& attribute.atAttribute.identifier.text == "property");
|
&& attribute.atAttribute.identifier.text == "property");
|
||||||
foundConst = foundConst || attribute.tokenType == tok!"const"
|
foundConst = foundConst || attribute.tokenType == tok!"const"
|
||||||
|| attribute.tokenType == tok!"immutable";
|
|| attribute.tokenType == tok!"immutable"
|
||||||
|
|| attribute.tokenType == tok!"inout";
|
||||||
}
|
}
|
||||||
if (foundProperty && !foundConst)
|
if (foundProperty && !foundConst)
|
||||||
{
|
{
|
||||||
addErrorMessage(dec.name.line, dec.name.column, KEY,
|
addErrorMessage(dec.name.line, dec.name.column, KEY,
|
||||||
"Zero-parameter '@property' function should be"
|
"Zero-parameter '@property' function should be"
|
||||||
~ " marked 'const'.");
|
~ " marked 'const', 'inout', or 'immutable'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dec.accept(this);
|
dec.accept(this);
|
||||||
|
|
Loading…
Reference in New Issue