Skip to content

add shift(<<, >>, >>>) operator #7183

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 16 commits into from
Apr 16, 2025
Merged

Conversation

gwansikk
Copy link
Contributor

@gwansikk gwansikk changed the title add left shift(<<) operator add shift(<<, >>, >>>) operator Dec 8, 2024
@cknitt
Copy link
Member

cknitt commented Feb 8, 2025

Hi @gwansikk! Would be great to get this PR merged - do you have time to pick up work on it again?

@gwansikk
Copy link
Contributor Author

gwansikk commented Feb 8, 2025

Hi @gwansikk! Would be great to get this PR merged - do you have time to pick up work on it again?

of course! I had been missing it due to personal matters. I will try to work on it as soon as possible.

@cknitt
Copy link
Member

cknitt commented Apr 2, 2025

This now has conflicts because I removed Pervasives_mini.res.
Could you rebase?

@gwansikk
Copy link
Contributor Author

gwansikk commented Apr 2, 2025

This now has conflicts because I removed Pervasives_mini.res. Could you rebase?

Got it! I’ll take care of it and aim to wrap up the task within this week. Apologies for the delay(this PR work).

@gwansikk
Copy link
Contributor Author

gwansikk commented Apr 6, 2025

This task is causing more issues than expected (JSX, type generic precedence, and syntax), so it may be delayed. I’ll try to complete it as soon as possible.

@cometkim
Copy link
Member

Yes, this turned out to be much harder than I expected.

JSX syntax consumes LessThan tokens and diamond syntax consumes even more of it.

In the last pair session, we found that modifying the core scanner loop was not working, so we explored converting it to a virtual token in the middle of the parser.

Mutations fooled us. Since it is scanner logic anyway, we discussed adding a custom method to the scanner instead of the parser.

@cometkim
Copy link
Member

@gwansikk fixed the implementation.

I realized I had been misguided, and your initial approach was almost close.

@cometkim cometkim mentioned this pull request Apr 11, 2025
@gwansikk gwansikk marked this pull request as ready for review April 11, 2025 16:55
@cometkim
Copy link
Member

5d308e7 removes additional parens, which makes no difference in behavior. It makes the output more compact but makes a readability issue in some nested structures.

Maybe we can put parens again depending on the expression depth.

@cknitt
Copy link
Member

cknitt commented Apr 12, 2025

Thank you for your work @gwansikk @cometkim!

Maybe we can put parens again depending on the expression depth.

Not saying that we need to do it the same way, but I had a look at what prettier does in some of the situations where our code formatting changes with this PR.

@cometkim
Copy link
Member

Not saying that we need to do it the same way, but I had a look at what prettier does in some of the situations where our code formatting changes with this PR.

That's good to know. They always add parens when it is mixed with bitwise operators. I thought it might be too much since we have | 0 semantics, but in fact for int shift we can always omit | 0.

Let's split the output change and review it separately in another PR.

@cometkim
Copy link
Member

cometkim commented Apr 16, 2025

Need rebase and the CHANGELOG.md entry

Done

gwansikk and others added 6 commits April 16, 2025 20:32
Co-authored-by: Hyeseong Kim <[email protected]>
I looked back at the last session with Gwansik and realized that,
I had misguided him by simply misunderstanding a particular syntx error.

Gwansik's initial approach was almost close.

Co-authored-by: gwansikk <[email protected]>
This reverts commit 5d308e7.
@cometkim
Copy link
Member

@cknitt Can we merge?

Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

👍

@cometkim cometkim merged commit 220b3d0 into rescript-lang:master Apr 16, 2025
20 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.

3 participants