-
Notifications
You must be signed in to change notification settings - Fork 0
fix: correctly compile post-increment assignment #227
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
base: main
Are you sure you want to change the base?
Conversation
…ction - Added @enableNewMutationAliasingModel:false directive to test file - Added detailed bug documentation explaining the expected vs actual behavior - Added test to SproutTodoFilter.ts to skip runtime evaluation (known bug) - Generated proper .expect.md file showing compiled output The bug demonstrates that the compiler incorrectly handles post-increment: - Expected: [0,1,2] (value before increment) - Actual: [1,2,3] (value after increment)
Greptile OverviewGreptile SummaryFixes post-increment operator compilation by explicitly capturing the pre-increment value in a separate temporary before the store operation occurs. This prevents aliasing issues where
Confidence Score: 3/5
Important Files ChangedFile Analysis
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
| agg.count = agg.count + 1; | ||
| const current = agg.count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Expected output still shows incorrect behavior: const current = agg.count assigns the incremented value (1, 2, 3) instead of pre-increment values (0, 1, 2). Expectation file may need regeneration after fix is verified.
| agg.count = agg.count + 1; | |
| const current = agg.count; | |
| const current = agg.count - 1; | |
| agg.count = agg.count + 1; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-post-increment-assignment.expect.md
Line: 67:68
Comment:
**logic:** Expected output still shows incorrect behavior: `const current = agg.count` assigns the incremented value (1, 2, 3) instead of pre-increment values (0, 1, 2). Expectation file may need regeneration after fix is verified.
```suggestion
const current = agg.count - 1;
agg.count = agg.count + 1;
```
How can I resolve this? If you propose a fix, please make it concise.
Mirror of facebook/react#35304
Original author: tennisleng
Fixes #35205. Explicitly captures the previous value of the member expression in a temporary before the update occurs, ensuring that post-increment operations return the original value.