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

Fix record field and jsx props punned when with attributes #2824

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pedrobslisboa
Copy link

@pedrobslisboa pedrobslisboa commented Jan 24, 2025

Issue #2822

Description

This PR adds validation for records fields and jsx props to avoid pun them when the have attributes

@@ -5239,7 +5243,8 @@ let createFormatter () =
let value_has_jsx = jsxAttrs != [] in
let nextAttr =
match expression.pexp_desc with
| Pexp_ident ident when isPunnedJsxArg lbl ident ->
| Pexp_ident ident
when isPunnedJsxArg lbl ident expression.pexp_attributes ->
Copy link
Member

Choose a reason for hiding this comment

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

you should use stdAttrs from the call to partitionAttributes above here.

@@ -5260,7 +5265,9 @@ let createFormatter () =
let value_has_jsx = jsxAttrs != [] in
let nextAttr =
match expression.pexp_desc with
| Pexp_ident ident when isPunnedJsxArg lbl ident -> atom lbl
| Pexp_ident ident
when isPunnedJsxArg lbl ident expression.pexp_attributes ->
Copy link
Member

Choose a reason for hiding this comment

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

same as above

(* don't turn {bar: Foo.bar, baz: 1} into {bar, baz: 1}, naturally *)
| Pexp_ident { txt = Lident value; _ }, true, true
when Longident.last_exn li.txt = value ->
when Longident.last_exn li.txt = value && e.pexp_attributes = []
Copy link
Member

Choose a reason for hiding this comment

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

I think we may need to partition attributes here too

Copy link
Member

@anmonteiro anmonteiro left a comment

Choose a reason for hiding this comment

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

thanks for solving this one! almost there

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