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 extensions printing #2674

Merged
merged 32 commits into from
Nov 21, 2022
Merged

Fix extensions printing #2674

merged 32 commits into from
Nov 21, 2022

Conversation

davesnx
Copy link
Member

@davesnx davesnx commented Oct 29, 2022

When printing code with refmt: Extensions are printed with and without brackets [] in some cases, creating a few problems:

  • Different expressions are treated differently when formatting (that might give the impression to be different expressions when they aren't)
  • Creates unbalance code where used inside branches

This PR tries to unify them to always add [] while respecting the inline let attributes added #1703.

@anmonteiro anmonteiro self-requested a review October 29, 2022 20:39
dune Outdated Show resolved Hide resolved
@@ -237,7 +237,10 @@ class boxB ('a) (init: 'a) =

/* To be able to put an attribute on just the return in that case, use
* parens. */
[@onBoxC x; y]
[@onBoxC
Copy link
Member

Choose a reason for hiding this comment

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

this one is a little awkward

Copy link
Member Author

Choose a reason for hiding this comment

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

At first, I found it weird but later made sense. Any structure_item inside an attribute should be treated like a structure_item without an attribute...

I can roll it back thought.

Copy link
Member

Choose a reason for hiding this comment

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

that does make sense. happy to keep it as is

[@someattr]
let foo: int => int;
};
module Foo: {[@someattr]
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in e17fe1b

Copy link
Member

Choose a reason for hiding this comment

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

very nice, thanks

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.

looks good, there's just the module case to fix

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.

LGTM. I think we're ready to land this

@davesnx davesnx merged commit 7592a8f into reasonml:master Nov 21, 2022
@davesnx davesnx deleted the fix-extensions branch January 30, 2023 20:24
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.

None yet

2 participants