Skip to content

Parser leading attr strictness #7787

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

Merged
merged 5 commits into from
Aug 23, 2025
Merged

Parser leading attr strictness #7787

merged 5 commits into from
Aug 23, 2025

Conversation

zth
Copy link
Member

@zth zth commented Aug 22, 2025

Follow up for #7782.

@zth zth force-pushed the parser-leading-attr-strictness branch from c91ae80 to 01158eb Compare August 22, 2025 09:24
@zth zth requested a review from cristianoc August 22, 2025 09:24
Copy link

pkg-pr-new bot commented Aug 22, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7787

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7787

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7787

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7787

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7787

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7787

commit: 945a61f

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

Looks great.
Just some comments on code duplication.

| Lbrace ->
(* consume the attributes and any doc comments before the record *)
ignore (parse_attributes p);
let rec skip_docs () =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same fun defined a few lines above.

| DotDot ->
(* attributes before an open variant marker; consume attrs/docs then handle `..` *)
ignore (parse_attributes p);
let rec skip_docs () =
Copy link
Collaborator

Choose a reason for hiding this comment

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

And here

Parser.lookahead p (fun state ->
ignore (parse_attributes state);
(* optionally skip a run of doc comments before deciding *)
let rec skip_docs () =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again

y: int }
type nonrec t = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The printer will also need attention. Perhaps for later and one can just add the issue for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean?

@zth zth force-pushed the parser-leading-attr-strictness branch from 01158eb to 4329600 Compare August 23, 2025 18:48
@zth zth enabled auto-merge (squash) August 23, 2025 18:49
@zth zth merged commit 18ff979 into master Aug 23, 2025
27 checks passed
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.

2 participants