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

PBJ processes document comments (i.e. /**...*/) as tokens #319

Open
jsync-swirlds opened this issue Nov 7, 2024 · 0 comments
Open

PBJ processes document comments (i.e. /**...*/) as tokens #319

jsync-swirlds opened this issue Nov 7, 2024 · 0 comments

Comments

@jsync-swirlds
Copy link
Member

Description

PBJ treats document comments (/**...*/) as the start of a token (because it wants to make them Javadoc), and if the comment is not followed by a field or message, that next item (be it a keyword like reserved or the end of a block }) is treated as a field or message, so it would look for a message type reserved or hoist a oneof to a field (both of which will fail). In some cases that will even cause a message to be processed completely incorrectly, but still appear to compile, so it's another subtly concerning bug.

How to Reproduce

Compile the following protobuf:

message DocumentCommentTest {
    /**
     * This will fail "cannot find type [reserved]".
     */
    reserved 5;

    /**
     * This is fine.
     */
    uint32 number = 1;

    /**
     * oneof with a commented field; this will fail compilation
     * "OneofFieldContext.fieldNumber is null"
     */
    oneof sample {
        /**
         * A text field
         */
        string text = 2;

        /**
         * A flag indicating FCOJ futures bids are enabled.
         */
        // removed for now. 
        // bool futures_enabled = 3;
    }
}
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

1 participant