Skip to content

Add jsx_tag_name #7760

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 12 commits into from
Aug 11, 2025
Merged

Add jsx_tag_name #7760

merged 12 commits into from
Aug 11, 2025

Conversation

nojaf
Copy link
Member

@nojaf nojaf commented Aug 10, 2025

Following up on the suggestion from @cristianoc.

Copy link

pkg-pr-new bot commented Aug 10, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit: 88f41f7

@nojaf nojaf requested a review from Copilot August 11, 2025 07:44
Copilot

This comment was marked as outdated.

@nojaf nojaf requested a review from Copilot August 11, 2025 09:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new jsx_tag_name type to improve JSX tag name handling in the ReScript compiler, replacing the previous Longident.t representation. The change enables better error handling for invalid JSX tag names and provides more precise differentiation between lowercase tags, qualified lowercase tags, and uppercase tags.

  • Introduces a new jsx_tag_name type with variants for different JSX tag categories
  • Updates JSX parsing logic to use the new type and provide better error messages
  • Refactors printer and analysis code to work with the new type structure

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
compiler/ml/parsetree.ml Adds new jsx_tag_name type definition with variants for different tag types
compiler/syntax/src/res_core.ml Replaces JSX parsing logic to use new tag name type
compiler/syntax/src/res_printer.ml Updates JSX printing to handle new tag name structure
compiler/ml/ast_helper.ml Adds utility functions for jsx_tag_name conversion
tests/syntax_tests/data/parsing/errors/expressions/jsx.res Adds test cases for trailing dots in JSX tag names
analysis/src/CompletionFrontEnd.ml Updates completion logic to handle new tag name type
jsx_v4.ml Updates JSX transformation to work with new tag name variants

"detail": "module Comp",
"documentation": null
}]
JSX <O.:__ghost__[0:-1->0:-1] > _children:None
Copy link
Member Author

Choose a reason for hiding this comment

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

This tests <0, which is nonsensical to begin with. I don't mind that we lose this single questionable completion here.

-> (
let name = Ast_helper.Jsx.string_of_jsx_tag_name tag_name.txt in
let tag_loc = tag_name.loc in
match tag_name.txt with
Copy link
Member Author

Choose a reason for hiding this comment

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

This highlights a good benefit of the AST change.

@nojaf nojaf marked this pull request as ready for review August 11, 2025 10:01
@nojaf nojaf requested a review from cristianoc August 11, 2025 10:01
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.

What's the verdict so far: do the changes seem worth it, in terms of code clarity?

@nojaf
Copy link
Member Author

nojaf commented Aug 11, 2025

@cristianoc yes, I like it. It makes things a bit more clear. The parser is very conscious about parsing jsx element tags and attributes. And the ppx also benefits from it.
I would be in favour of having this if you agree.

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.

Let's go for it!
Since the syntax tests look good, this should be safe.

@nojaf nojaf merged commit 6d4e83e into rescript-lang:master Aug 11, 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