Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not expect that first word in comment line is name of result variable #301

Open
Pzixel opened this issue Jun 10, 2021 · 5 comments
Open

Comments

@Pzixel
Copy link

Pzixel commented Jun 10, 2021

Consider following method and comment:

/// @return Some value
function foo() external view returns(uint256) {
    return 0;
}

When it get parsed with parseNatSpec function it parses Some as response variable name and the rest as its description. But natspec doesn't have any requirements on format of return and it makes total sense to omit it at all when there is only one return value

@Pzixel
Copy link
Author

Pzixel commented Jun 10, 2021

There is a comment about its format:

If your function returns multiple values, like (int quotient, int remainder) then use multiple @return statements in the same format as the @param statements.

But their own example with Tree shows that it only applies when function has more than one output value

@frangio
Copy link
Contributor

frangio commented Jun 10, 2021

Thanks for pointing this out. We're indeed assuming the wrong format in our parsing.

@frangio
Copy link
Contributor

frangio commented Jan 4, 2022

It seems that if the function declares names for return values (as in returns (uint a)) then the NatSpec syntax expects the variable name, otherwise it doesn't.

@Pzixel
Copy link
Author

Pzixel commented Jan 4, 2022

Right, but it still should possible to add comment to function result, even if it's anonymous. It should be then somehing like:

result.name // undefined
result.description // 'Some value'

@frangio
Copy link
Contributor

frangio commented Jan 5, 2022

Yes, I was able to reproduce the behavior implemented by solc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants