You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix the lexer so that //// (four or more slashes) is classified as a regular TokenSingleLineComment rather than a TokenSingleLineDocComment. Previously, any line starting with /// was treated as a doc comment, including ////, ////, etc. Now, only exactly /// (where the fourth character is not /) is recognized as a doc comment, aligning the lexer with cairo-lang-doc's behavior of discarding doc comments whose content begins with /.
A test is added to verify that // regular, /// doc, //! inner, ////, and ///// are each classified into the correct token kinds.
Type of change
Please check one:
Bug fix (fixes incorrect behavior)
New feature
Performance improvement
Documentation change with concrete technical impact
Style, wording, formatting, or typo-only change
Why is this change needed?
cairo-lang-doc already discards any doc comment whose content starts with /, meaning //// was never treated as a real doc comment at the documentation-generation level. However, the lexer was still emitting TokenSingleLineDocComment for ////, creating an inconsistency between the lexer's token classification and how the doc tooling actually interprets those tokens.
What was the behavior or documentation before?
Any comment beginning with /// — including ////, /////, etc. — was lexed as TokenSingleLineDocComment.
What is the behavior or documentation after?
Only /// where the fourth character is not / is lexed as TokenSingleLineDocComment. Four or more consecutive slashes produce a plain TokenSingleLineComment, consistent with cairo-lang-doc.
Related issue or discussion (if any)
N/A
Additional context
The guard self.peek_nth(3) != Some('/') is added to the Some('/') match arm in match_trivium_single_line_comment, and a dedicated test test_doc_comment_classification covers all relevant cases.
Low Risk
Narrow lexer trivia classification fix with a dedicated test; no auth, data, or broad parser behavior changes beyond ////+ comment lines.
Overview
Fixes a lexer/doc tooling mismatch: lines with four or more leading slashes (////, /////, …) are now TokenSingleLineComment instead of TokenSingleLineDocComment.
In match_trivium_single_line_comment, the /// arm only applies when the fourth character is not another / (peek_nth(3) != Some('/')), so exactly /// stays a doc comment while //! inner docs are unchanged.
Adds test_doc_comment_classification to assert trivia kinds for //, ///, //!, ////, and /////, aligned with cairo-lang-doc ignoring doc comments whose content starts with /.
Reviewed by Cursor Bugbot for commit 4fc0ccf. Bugbot is set up for automated code reviews on this repo. Configure here.
The reason will be displayed to describe this comment to others. Learn more.
@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment. Reviewable status: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the lexer so that
////(four or more slashes) is classified as a regularTokenSingleLineCommentrather than aTokenSingleLineDocComment. Previously, any line starting with///was treated as a doc comment, including////,////, etc. Now, only exactly///(where the fourth character is not/) is recognized as a doc comment, aligning the lexer withcairo-lang-doc's behavior of discarding doc comments whose content begins with/.A test is added to verify that
// regular,/// doc,//! inner,////, and/////are each classified into the correct token kinds.Type of change
Please check one:
Why is this change needed?
cairo-lang-docalready discards any doc comment whose content starts with/, meaning////was never treated as a real doc comment at the documentation-generation level. However, the lexer was still emittingTokenSingleLineDocCommentfor////, creating an inconsistency between the lexer's token classification and how the doc tooling actually interprets those tokens.What was the behavior or documentation before?
Any comment beginning with
///— including////,/////, etc. — was lexed asTokenSingleLineDocComment.What is the behavior or documentation after?
Only
///where the fourth character is not/is lexed asTokenSingleLineDocComment. Four or more consecutive slashes produce a plainTokenSingleLineComment, consistent withcairo-lang-doc.Related issue or discussion (if any)
N/A
Additional context
The guard
self.peek_nth(3) != Some('/')is added to theSome('/')match arm inmatch_trivium_single_line_comment, and a dedicated testtest_doc_comment_classificationcovers all relevant cases.