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

[compiler] Support for member expression inc/decrement #30697

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

mvitousek
Copy link
Contributor

@mvitousek mvitousek commented Aug 14, 2024

Stack from ghstack (oldest at bottom):

Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

[ghstack-poisoned]
Copy link

vercel bot commented Aug 14, 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 Aug 15, 2024 6:41pm

mvitousek added a commit that referenced this pull request Aug 14, 2024
Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

ghstack-source-id: 9009bc1eb53565cebe66152956184df70036b02a
Pull Request resolved: #30697
Comment on lines +2442 to +2448
return {
kind: 'LoadLocal',
place: expr.node.prefix
? {...newValuePlace}
: {...previousValuePlace},
loc: exprLoc,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fine, but we try to avoid using lvalues more than once. The main exception is for method calls, where we evaluate the receiver to an lvalue, then use that lvalue to load the property for the method and again as the receiver of the method call instruction.

To test, can you add some fixtures where the increment/decrement is used as an rvalue? let x = obj.x++ and (obj.x++).toString()

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.

Awesome! Please see comments before landing with some additional things to test

Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

[ghstack-poisoned]
mvitousek added a commit that referenced this pull request Aug 15, 2024
Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

ghstack-source-id: 8f3979913aad561cdba70464c3cc5f0ee95887b5
Pull Request resolved: #30697
@mvitousek mvitousek merged commit 84098f3 into gh/mvitousek/23/base Aug 15, 2024
19 checks passed
mvitousek added a commit that referenced this pull request Aug 15, 2024
Test Plan:
Builds support for a.x++ and friends. Similar to a.x += y, emits it as an assignment expression.

ghstack-source-id: 8f3979913aad561cdba70464c3cc5f0ee95887b5
Pull Request resolved: #30697
@mvitousek mvitousek deleted the gh/mvitousek/23/head branch August 15, 2024 19:00
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.

3 participants