Skip to content

Commit 3975408

Browse files
committed
NatSpec: Disallow @return tag on events.
Ethereum events do not declare return parameters, unlike functions. The event branch of callable documentation incorrectly accepted the same tag set as functions, allowing misleading `@return` markup. Restrict event validation to `dev`, `notice`, and `param`, consistent with errors.
1 parent 402ee27 commit 3975408

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Language Features:
55
Compiler Features:
66

77
Bugfixes:
8+
* NatSpec: Disallow ``@return`` tags on event documentation; events do not have return parameters (consistent with errors).
89

910

1011
### 0.8.35 (2026-04-29)

libsolidity/analysis/DocStringTagParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void DocStringTagParser::handleCallable(
285285
StructurallyDocumentedAnnotation& _annotation
286286
)
287287
{
288-
static std::set<std::string> const validEventTags = std::set<std::string>{"dev", "notice", "return", "param"};
288+
static std::set<std::string> const validEventTags = std::set<std::string>{"dev", "notice", "param"};
289289
static std::set<std::string> const validErrorTags = std::set<std::string>{"dev", "notice", "param"};
290290
static std::set<std::string> const validModifierTags = std::set<std::string>{"dev", "notice", "param", "inheritdoc"};
291291
static std::set<std::string> const validTags = std::set<std::string>{"dev", "notice", "return", "param", "inheritdoc"};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
contract C {
2+
/// @return foo
3+
event E(uint x);
4+
}
5+
// ----
6+
// DocstringParsingError 6546: (14-29): Documentation tag @return not valid for events.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
interface I {
2+
/// @return foo
3+
event E(uint x);
4+
}
5+
contract C is I {
6+
}
7+
// ----
8+
// DocstringParsingError 6546: (15-30): Documentation tag @return not valid for events.

0 commit comments

Comments
 (0)