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(react-compiler): implement NumericLiteral as ObjectPropertyKey #31791

Merged

Conversation

dimaMachina
Copy link
Contributor

Copy link

vercel bot commented Dec 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 30, 2024 9:16am

@facebook-github-bot
Copy link

Hi @dimaMachina!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@abhishekgautam95

This comment was marked as spam.

@dimaMachina
Copy link
Contributor Author

dimaMachina commented Jan 10, 2025

friendly ping @josephsavona as you requested to create PR with fix in twitter

@abhishekgautam95

This comment was marked as spam.

@josephsavona
Copy link
Contributor

Yeah, will take a look tomorrow

21: 'dimaMachina'
}
return <div>{obj[21]}</div>
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a fixture here so that we can test evaluation with/without compilation:

export const FIXTURE_ENTRYPOINT = {
  fn: Test,
  params: [{}],
};

Copy link
Contributor

Choose a reason for hiding this comment

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

also be sure to update fixtures after this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Updated! Could you also review my other contribution to the react compiler? #31792

I just pushed there similar change 🙂

Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

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

Just one change, then this should be good to land. Thanks!

@abhishekgautam95
Copy link

abhishekgautam95 commented Jan 10, 2025 via email

@dimaMachina
Copy link
Contributor Author

@josephsavona friendly ping 🙏

@mofeiZ
Copy link
Contributor

mofeiZ commented Feb 27, 2025

Thanks for the contribution! Please run yarn prettier at the root (react/) to format changed files before landing

@dimaMachina
Copy link
Contributor Author

@mofeiZ ty, done!

@dimaMachina
Copy link
Contributor Author

@mofeiZ friendly ping

Comment on lines +1458 to +1462
} else if (key.isNumericLiteral()) {
return {
kind: 'identifier',
name: String(key.node.value),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also avoid converting numeric literals to babel identifiers. Could you

  1. Add a 'number' variant to HIR:ObjectPropertyKey
  2. Check for the number variant in codegenReactiveFunction:codegenObjectPropertyKey and return a t.numericLiteral

Let's also add a test case for destructuring assignment, which also uses ObjectExpressions

const {21: myVar} = obj;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mofeiZ thanks for your review, done in 5499ae1

Should I move destructuring assignment test to a separate file?

Copy link
Contributor

@mofeiZ mofeiZ Mar 17, 2025

Choose a reason for hiding this comment

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

Awesome, thanks for the quick fix! Just started a test run and will merge once everything passes

Should I move destructuring assignment test to a separate file?

This should be fine.

Copy link
Contributor Author

@dimaMachina dimaMachina Mar 17, 2025

Choose a reason for hiding this comment

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

Great, updated snapshot in 1fb22ae

@mofeiZ mofeiZ merged commit 90b511e into facebook:main Mar 17, 2025
21 checks passed
@dimaMachina dimaMachina deleted the numeric-literal-as-object-property-key branch March 17, 2025 23:33
@dimaMachina
Copy link
Contributor Author

@mofeiZ huge thanks to finally getting this merged 🥳 would you have time to review my other tiny contribution to react compiler in #31792 ? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants