mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Reports doctring error on named return mismatch.
This commit is contained in:
parent
bd26da8d37
commit
e5cb0fe839
@ -129,9 +129,36 @@ void DocStringAnalyser::parseDocStrings(
|
|||||||
m_errorOccured = true;
|
m_errorOccured = true;
|
||||||
_annotation.docTags = parser.tags();
|
_annotation.docTags = parser.tags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t returnTagsVisited = 0;
|
||||||
for (auto const& docTag: _annotation.docTags)
|
for (auto const& docTag: _annotation.docTags)
|
||||||
|
{
|
||||||
if (!_validTags.count(docTag.first))
|
if (!_validTags.count(docTag.first))
|
||||||
appendError("Doc tag @" + docTag.first + " not valid for " + _nodeName + ".");
|
appendError("Doc tag @" + docTag.first + " not valid for " + _nodeName + ".");
|
||||||
|
else
|
||||||
|
if (docTag.first == "return")
|
||||||
|
{
|
||||||
|
returnTagsVisited++;
|
||||||
|
if (auto* function = dynamic_cast<FunctionDefinition const*>(&_node))
|
||||||
|
{
|
||||||
|
string content = docTag.second.content;
|
||||||
|
string firstWord = content.substr(0, content.find_first_of(" \t"));
|
||||||
|
|
||||||
|
if (returnTagsVisited > function->returnParameters().size())
|
||||||
|
appendError("Doc tag \"@" + docTag.first + " " + docTag.second.content + "\"" +
|
||||||
|
" exceedes the number of return parameters."
|
||||||
|
);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto parameter = function->returnParameters().at(returnTagsVisited - 1);
|
||||||
|
if (!parameter->name().empty() && parameter->name() != firstWord)
|
||||||
|
appendError("Doc tag \"@" + docTag.first + " " + docTag.second.content + "\"" +
|
||||||
|
" does not contain the name of its return parameter."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocStringAnalyser::appendError(string const& _description)
|
void DocStringAnalyser::appendError(string const& _description)
|
||||||
|
@ -12831,7 +12831,7 @@ BOOST_AUTO_TEST_CASE(snark)
|
|||||||
return G1Point(p.X, q - (p.Y % q));
|
return G1Point(p.X, q - (p.Y % q));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the sum of two points of G1
|
/// @return r the sum of two points of G1
|
||||||
function add(G1Point memory p1, G1Point memory p2) internal returns (G1Point memory r) {
|
function add(G1Point memory p1, G1Point memory p2) internal returns (G1Point memory r) {
|
||||||
uint[4] memory input;
|
uint[4] memory input;
|
||||||
input[0] = p1.X;
|
input[0] = p1.X;
|
||||||
@ -12847,7 +12847,7 @@ BOOST_AUTO_TEST_CASE(snark)
|
|||||||
require(success);
|
require(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the product of a point on G1 and a scalar, i.e.
|
/// @return r the product of a point on G1 and a scalar, i.e.
|
||||||
/// p == p.mul(1) and p.add(p) == p.mul(2) for all points p.
|
/// p == p.mul(1) and p.add(p) == p.mul(2) for all points p.
|
||||||
function mul(G1Point memory p, uint s) internal returns (G1Point memory r) {
|
function mul(G1Point memory p, uint s) internal returns (G1Point memory r) {
|
||||||
uint[3] memory input;
|
uint[3] memory input;
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
abstract contract C {
|
||||||
|
/// @return value The value returned by this function.
|
||||||
|
function vote() public virtual returns (uint value);
|
||||||
|
}
|
||||||
|
// ----
|
@ -0,0 +1,7 @@
|
|||||||
|
abstract contract C {
|
||||||
|
/// @param id Some identifier
|
||||||
|
/// @return No value returned
|
||||||
|
function vote(uint id) public virtual returns (uint value);
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DocstringParsingError: Doc tag "@return No value returned" does not contain the name of its return parameter.
|
@ -0,0 +1,7 @@
|
|||||||
|
abstract contract C {
|
||||||
|
/// @param id Some identifier
|
||||||
|
/// @return No value returned
|
||||||
|
function vote(uint id) public virtual returns (uint value);
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DocstringParsingError: Doc tag "@return No value returned" does not contain the name of its return parameter.
|
Loading…
Reference in New Issue
Block a user