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

Multiple @return! statements in code docs #1551

Open
vssukharev opened this issue Oct 12, 2024 · 2 comments
Open

Multiple @return! statements in code docs #1551

vssukharev opened this issue Oct 12, 2024 · 2 comments
Assignees
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works
Milestone

Comments

@vssukharev
Copy link

For example, I have such code

/**
 * Parses command-line arguments
 * 
 * @param [in] args
 * @param [out] res_args
 *
 * @return! CommandArgsErr.INVALID_SRC_FILE
 * @return! CommandArgsErr.INVALID_OUT_FILE
 * @return! CommandArgsErr.TOO_FEW_ARGUMENTS
 */
fn void! parseCommandArgs(String[] args, CommandArgs* res_args)
{
  if (args.len == 1) {
    hlp::printFuncErrN("Too few arguments");
    return CommandArgsErr.TOO_FEW_ARGUMENTS?;
  }

  for (usz i = 0; i < args.len; ++i) {
    parseFlagSource(args, i, &res_args.src_path);
  }
}

Here, I want @return! to be declared multiple times to avoid too long line with the amount of possible excuses.
This code is actually compiled but if I swap @return! blocks by moving TOO_FEW_ARGUMENTS on top:

/**
 * Parses command-line arguments
 * 
 * @param [in] args
 * @param [out] res_args
 *
 * @return! CommandArgsErr.TOO_FEW_ARGUMENTS
 * @return! CommandArgsErr.INVALID_SRC_FILE
 * @return! CommandArgsErr.INVALID_OUT_FILE
 */

I get an error:

49: {
 50:   if (args.len == 1) {
 51:     hlp::printFuncErrN("Too few arguments");
 52:     return CommandArgsErr.TOO_FEW_ARGUMENTS?;
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(/home/starleks/coding/c3-binder/src/helpers/command-args.c3:52:12) Error: This value does not match declared optional returns, it needs to be declared with the other optional returns.

So I propose to write multiple @return! statements in docs instead of writing @return! EXCUSE_1, EXCUSE_2, EXCUSE_3.

@lerno lerno self-assigned this Oct 12, 2024
@lerno lerno added the Bug Something isn't working label Oct 12, 2024
@lerno
Copy link
Collaborator

lerno commented Oct 13, 2024

This will start working again with this pull request: #1555

@lerno lerno added the Fixed Needs Verification Fixed, but needs verification that it works label Oct 13, 2024
@lerno
Copy link
Collaborator

lerno commented Oct 15, 2024

This should now work:

<*
 Parses command-line arguments
  
 @param [in] args
 @param [out] res_args
 @return! CommandArgsErr.INVALID_SRC_FILE
 @return! CommandArgsErr.INVALID_OUT_FILE
 @return! CommandArgsErr.TOO_FEW_ARGUMENTS
*>

Note that if it can throw ANY CommandArgsErr, then you can always write: @return! CommandArgsErr

@lerno lerno added this to the 0.6.4 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works
Projects
None yet
Development

No branches or pull requests

2 participants