-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Generate proper parser errors for NatSpec documentation #7835
Comments
I see a PR from you @erak so it seems you're working on this. Assigning you |
I think we need to discuss the last point: "In order to report errors and their source location correctly, an additional AST node for every tag is needed." I did some hacking on that and realized a few things that might need more work than initially thought:
So I would propose to post-pone the last step and at least report the location of the full documentation string in which the error occured. This will be done with: #8221. Does anyone have further thoughts or opinions? |
You are right, this sounds rather difficult with the current architecture. |
Abstract
With #7534, we introduced a (partially) breaking change: the developer documentation of a function must contain a
@return
tag for every named return parameter and define the parameter name as the first word after the tag. Compiling without--devdoc
is still fine, but requesting it, leads to an Internal Compiler Error.We should generate proper parser errors in the analyzation phase of a NatSpec string.
This will require some changes to the AST, since documentation needs to become an ASTNode such that it can provide source locations and, in a subsequent step, even every tag as an individual ASTNode which we can pinpoint to in case of an error.
Motivation
Consider the following contract in a file called
Test.sol
Compiling it with
solc Test.sol
will succeed. Requesting the developer documentation usingsolc --devdoc
will result in an Internal Compiler Error because/// @return A value
does not contain the name of the return parameter as the first word after the tag.Also, our source upgrade tool (
solidity-upgrade
), that is currently in development, will profit from source locations, because it would be also able to upgrade documentation then.Specification
A minimal solution for the 0.6.0 release could be the generation of a
DocStringError
without source location. That would at least make the change a consistently breaking one --> Report DocString error on named return paramater mismatch #7837The next step could be the introduction of a
DocString
node to the AST, and theDocumented
class having a pointer to it (instead ofASTString
) --> [natspec] Introduce AST node for structured documentation #7834After the AST node was introduced, report source locations at least for every single or multiline comment, spanning over the whole documentation string -> [parser] Source locations for structured documentation errors #8221
In order to report errors and their source location correctly, an additional AST node for every tag is needed.
The text was updated successfully, but these errors were encountered: