mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11167 from ethereum/natspec-custom
Show proper error for misusing the custom natspec tag
This commit is contained in:
commit
4cfb1e5cae
@ -163,7 +163,13 @@ void DocStringTagParser::parseDocStrings(
|
|||||||
for (auto const& [tagName, tagValue]: _annotation.docTags)
|
for (auto const& [tagName, tagValue]: _annotation.docTags)
|
||||||
{
|
{
|
||||||
string static const customPrefix("custom:");
|
string static const customPrefix("custom:");
|
||||||
if (boost::starts_with(tagName, customPrefix) && tagName.size() > customPrefix.size())
|
if (tagName == "custom" || tagName == "custom:")
|
||||||
|
m_errorReporter.docstringParsingError(
|
||||||
|
6564_error,
|
||||||
|
_node.documentation()->location(),
|
||||||
|
"Custom documentation tag must contain a chosen name, i.e. @custom:mytag."
|
||||||
|
);
|
||||||
|
else if (boost::starts_with(tagName, customPrefix) && tagName.size() > customPrefix.size())
|
||||||
{
|
{
|
||||||
regex static const customRegex("^custom:[a-z][a-z-]*$");
|
regex static const customRegex("^custom:[a-z][a-z-]*$");
|
||||||
if (!regex_match(tagName, customRegex))
|
if (!regex_match(tagName, customRegex))
|
||||||
|
@ -8,9 +8,12 @@ contract C {
|
|||||||
function h() public pure {}
|
function h() public pure {}
|
||||||
/// @custom:abc-def
|
/// @custom:abc-def
|
||||||
function i() public pure {}
|
function i() public pure {}
|
||||||
|
/// @custom
|
||||||
|
function j() public pure {}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// DocstringParsingError 6546: (0-14): Documentation tag @a&b not valid for contracts.
|
// DocstringParsingError 6546: (0-14): Documentation tag @a&b not valid for contracts.
|
||||||
// DocstringParsingError 2968: (28-49): Invalid character in custom tag @custom:x^y. Only lowercase letters and "-" are permitted.
|
// DocstringParsingError 2968: (28-49): Invalid character in custom tag @custom:x^y. Only lowercase letters and "-" are permitted.
|
||||||
// DocstringParsingError 6546: (80-92): Documentation tag @custom: not valid for functions.
|
// DocstringParsingError 6564: (80-92): Custom documentation tag must contain a chosen name, i.e. @custom:mytag.
|
||||||
// DocstringParsingError 2968: (123-141): Invalid character in custom tag @custom:abcDEF. Only lowercase letters and "-" are permitted.
|
// DocstringParsingError 2968: (123-141): Invalid character in custom tag @custom:abcDEF. Only lowercase letters and "-" are permitted.
|
||||||
|
// DocstringParsingError 6564: (222-233): Custom documentation tag must contain a chosen name, i.e. @custom:mytag.
|
||||||
|
Loading…
Reference in New Issue
Block a user