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

Doc comments on functions warn unexpectedly #7711

Closed
vezenovm opened this issue Mar 14, 2025 · 0 comments · Fixed by #7721
Closed

Doc comments on functions warn unexpectedly #7711

vezenovm opened this issue Mar 14, 2025 · 0 comments · Fixed by #7721
Labels
bug Something isn't working parser issues primarily related to the parser

Comments

@vezenovm
Copy link
Contributor

vezenovm commented Mar 14, 2025

Aim

I want to add doc comments to our foreign functions in the stdlib. This is what an example signature looks like now:

#[foreign(ecdsa_secp256k1)]
// docs:start:ecdsa_secp256k1
pub fn verify_signature<let N: u32>(
    public_key_x: [u8; 32],
    public_key_y: [u8; 32],
    signature: [u8; 64],
    message_hash: [u8; N],
) -> bool
// docs:end:ecdsa_secp256k1
{}

I want to be able to add doc comments on a parameter such as:

#[foreign(ecdsa_secp256k1)]
// docs:start:ecdsa_secp256k1
pub fn verify_signature<let N: u32>(
    public_key_x: [u8; 32],
    public_key_y: [u8; 32],
    /// Insert doc comments here
    /// I love documentation
    signature: [u8; 64],
    message_hash: [u8; N],
) -> bool
// docs:end:ecdsa_secp256k1
{}

Or on the function itself:

#[foreign(ecdsa_secp256k1)]
// docs:start:ecdsa_secp256k1
/// Insert doc comments here
/// I love documentation
pub fn verify_signature<let N: u32>(
    public_key_x: [u8; 32],
    public_key_y: [u8; 32],
    signature: [u8; 64],
    message_hash: [u8; N],
) -> bool
// docs:end:ecdsa_secp256k1
{}

Expected Behavior

Successfully add doc comments on the function itself.

When adding doc comments on parameters I expect an error similar to the one we see in Rust:
Image

Bug

Adding doc comments on the parameter gives warnings over the entire doc comment:
Image

Putting the doc comments on the function itself but after the attribute causes the first line of the doc comments to trigger with a warning and the return value errors with expected bool, found type ()
Image

Doc comments work when placed before the attribute:
Image

However, we should be able to place doc comments before or after the attribute. Doc comments work as expected on functions without attributes as well.

To Reproduce

  1. Try to add doc comments to any noir function parameters or a function with attributes

Workaround

Yes

Workaround Description

Regular comments that use //

Additional Context

No response

Project Impact

Blocker

Blocker Context

Cannot place doc comments on function parameters

Nargo Version

nargo version = 1.0.0-beta.3 noirc version = 1.0.0-beta.3+5e2b9e9f1a8ac639acdb204be291739fa50f2ff5 (git version hash: 5e2b9e9, is dirty: true)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@vezenovm vezenovm added bug Something isn't working parser issues primarily related to the parser labels Mar 14, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Mar 14, 2025
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser issues primarily related to the parser
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant