Skip to content

[v2] Fix multiline natspec comment lexing#1470

Merged
teofr merged 2 commits intomainfrom
teofr/fix-multiline-natspec
Nov 18, 2025
Merged

[v2] Fix multiline natspec comment lexing#1470
teofr merged 2 commits intomainfrom
teofr/fix-multiline-natspec

Conversation

@teofr
Copy link
Contributor

@teofr teofr commented Nov 13, 2025

Fixes #1469

Goes from matching multiline NatSpec comments with r#"/\*\*[^\*]*\*+([^/\*][^\*]*\*+)*/"# to r#"/\*\*([^/\*][^\*]*)?\*+([^/\*][^\*]*\*+)*/"#.

The main difference is that immediately after the /** a character different than / is expected.

A sourcify run over all the chains shows a few errors, but I think these are different. Still, a lot less failing contracts than before.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: 5343164

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@teofr teofr marked this pull request as ready for review November 13, 2025 10:44
@teofr teofr requested review from a team as code owners November 13, 2025 10:44
@teofr
Copy link
Contributor Author

teofr commented Nov 13, 2025

Just as a note, while thinking on ways to solve this one option was to use a different mode for parsing multiline NatSpec comments. I don't think it's worth it for now, but it could be interested for our parser to give NatSpec comments a structure.

@teofr teofr marked this pull request as draft November 13, 2025 11:05
@teofr teofr force-pushed the teofr/fix-multiline-natspec branch from aa3885a to 5343164 Compare November 13, 2025 11:14
@teofr
Copy link
Contributor Author

teofr commented Nov 13, 2025

After some experimenting with Remix, it seems a comment with 3 asterisks (/*** */) is not considered a NatSpec comment, I tried adding that modification here but it differs too much from the V1 lexer. Maybe worth it doing it on a separate PR and fix the V1 lexer?

I think it's enough to remove the ? from the regex (ie r#"/\*\*[^/\*][^\*]*\*+([^/\*][^\*]*\*+)*/"#)

@teofr teofr marked this pull request as ready for review November 13, 2025 11:16
@teofr teofr enabled auto-merge November 13, 2025 17:51
Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@teofr teofr added this pull request to the merge queue Nov 18, 2025
Merged via the queue into main with commit 7fbf4d2 Nov 18, 2025
144 checks passed
@teofr teofr deleted the teofr/fix-multiline-natspec branch November 18, 2025 20:33
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

Successfully merging this pull request may close these issues.

v2 lexer matching multiple trivia

2 participants