@@ -119,9 +119,13 @@ impl Validate for FunctionDefinition {
119
119
if self . name == "receive" || self . name == "fallback" {
120
120
return out;
121
121
}
122
- // raise error if no NatSpec is available (unless there are no params and we don't enforce inheritdoc)
122
+ // raise error if no NatSpec is available (unless there are no params, no returns, and we don't enforce
123
+ // inheritdoc)
123
124
let Some ( natspec) = & self . natspec else {
124
- if self . params . is_empty ( ) && ( !options. inheritdoc || !self . requires_inheritdoc ( ) ) {
125
+ if self . returns . is_empty ( )
126
+ && self . params . is_empty ( )
127
+ && ( !options. inheritdoc || !self . requires_inheritdoc ( ) )
128
+ {
125
129
return out;
126
130
}
127
131
// we require natspec for either inheritdoc or the params
@@ -156,6 +160,7 @@ impl Validate for FunctionDefinition {
156
160
#[ cfg( test) ]
157
161
mod tests {
158
162
use semver:: Version ;
163
+ use similar_asserts:: assert_eq;
159
164
use slang_solidity:: parser:: Parser ;
160
165
161
166
use super :: * ;
@@ -362,4 +367,17 @@ mod tests {
362
367
assert_eq ! ( res. diags. len( ) , 1 ) ;
363
368
assert_eq ! ( res. diags[ 0 ] . message, "@inheritdoc is missing" ) ;
364
369
}
370
+
371
+ #[ test]
372
+ fn test_function_internal ( ) {
373
+ let contents = "contract Test {
374
+ // @notice
375
+ function _viewInternal() internal view returns (uint256) {
376
+ return 1;
377
+ }
378
+ }" ;
379
+ let res = parse_file ( contents) . validate ( & OPTIONS ) ;
380
+ assert_eq ! ( res. diags. len( ) , 1 ) ;
381
+ assert_eq ! ( res. diags[ 0 ] . message, "missing NatSpec" ) ;
382
+ }
365
383
}
0 commit comments