Merge pull request #9277 from a3d4/improve-docstringparser-error-coverage

Add a missing DocStringParser error to tests
This commit is contained in:
chriseth 2020-07-01 18:17:09 +02:00 committed by GitHub
commit 1ec1166a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 21 deletions

View File

@ -94,19 +94,12 @@ void DocStringParser::parse(string const& _docString, ErrorReporter& _errorRepor
{
// we found a tag
auto tagNameEndPos = firstWhitespaceOrNewline(tagPos, end);
if (tagNameEndPos == end)
{
m_errorReporter->docstringParsingError(
9222_error,
"End of tag " + string(tagPos, tagNameEndPos) + " not found"
);
break;
}
currPos = parseDocTag(tagNameEndPos + 1, end, string(tagPos + 1, tagNameEndPos));
auto tagName = string(tagPos + 1, tagNameEndPos);
auto tagDataPos = (tagNameEndPos != end) ? tagNameEndPos + 1 : tagNameEndPos;
currPos = parseDocTag(tagDataPos, end, tagName);
}
else if (!!m_lastTag) // continuation of the previous tag
currPos = appendDocTag(currPos, end);
currPos = parseDocTagLine(currPos, end, true);
else if (currPos != end)
{
// if it begins without a tag then consider it as @notice
@ -127,7 +120,7 @@ DocStringParser::iter DocStringParser::parseDocTagLine(iter _pos, iter _end, boo
{
solAssert(!!m_lastTag, "");
auto nlPos = find(_pos, _end, '\n');
if (_appending && _pos < _end && *_pos != ' ' && *_pos != '\t')
if (_appending && _pos != _end && *_pos != ' ' && *_pos != '\t')
m_lastTag->content += " ";
else if (!_appending)
_pos = skipWhitespace(_pos, _end);
@ -179,13 +172,7 @@ DocStringParser::iter DocStringParser::parseDocTag(iter _pos, iter _end, string
}
}
else
return appendDocTag(_pos, _end);
}
DocStringParser::iter DocStringParser::appendDocTag(iter _pos, iter _end)
{
solAssert(!!m_lastTag, "");
return parseDocTagLine(_pos, _end, true);
return parseDocTagLine(_pos, _end, true);
}
void DocStringParser::newTag(string const& _tagName)

View File

@ -50,7 +50,6 @@ private:
iter parseDocTagParam(iter _pos, iter _end);
iter appendDocTagParam(iter _pos, iter _end);
void parseDocString(std::string const& _string);
iter appendDocTag(iter _pos, iter _end);
/// Parses the doc tag named @a _tag, adds it to m_docTags and returns the position
/// after the tag.
iter parseDocTag(iter _pos, iter _end, std::string const& _tag);

View File

@ -3,4 +3,4 @@ abstract contract C {
function vote(uint id) public {}
}
// ----
// DocstringParsingError 9222: End of tag @param not found
// DocstringParsingError 3335: No param name given