From 0ea5aae9aa4d458f90f4b4eb3c61f0767c5632bf Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Aug 2020 12:13:23 +0200 Subject: [PATCH] Require inheritdoc tag to be non-empty. --- libsolidity/analysis/ReferencesResolver.cpp | 10 ++++++++++ .../natspec/invalid/docstring_inheritdoc_emptys.sol | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_emptys.sol diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index e2e92a126..208749de9 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -313,6 +313,16 @@ void ReferencesResolver::resolveInheritDoc(StructuredDocumentation const& _docum case 1: { string const& name = _annotation.docTags.find("inheritdoc")->second.content; + if (name.empty()) + { + m_errorReporter.docstringParsingError( + 1933_error, + _documentation.location(), + "Expected contract name following documentation tag @inheritdoc." + ); + return; + } + vector path; boost::split(path, name, boost::is_any_of(".")); Declaration const* result = m_resolver.pathFromCurrentScope(path); diff --git a/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_emptys.sol b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_emptys.sol new file mode 100644 index 000000000..e518021b4 --- /dev/null +++ b/test/libsolidity/syntaxTests/natspec/invalid/docstring_inheritdoc_emptys.sol @@ -0,0 +1,7 @@ +contract C { + /// @inheritdoc + function f() internal { + } +} +// ---- +// DocstringParsingError 1933: (17-32): Expected contract name following documentation tag @inheritdoc.