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

Parens hugging for Js.t obj types #2074

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

anmonteiro
Copy link
Member

fixes #2073

@IwanKaramazow
Copy link
Contributor

This is the correct approach.
There's another issue where we should format the Ptyp_constr on the same line as type foo =

type foo = array({    -> notice how "array" sticks to "type foo"
...
});

This is a much bigger project on it's own, touching the internals of type declaration.
I propose that we solve this in another PR.

@@ -3037,6 +3037,10 @@ let printer = object(self:'self)
| [{ptyp_desc = Ptyp_object (l, o) }] when not (isJsDotTLongIdent li.txt) ->
label (self#longident_loc li)
(self#unparseObject ~wrap:("(",")") l o)
| [{ptyp_desc = Ptyp_constr(lii, [{ ptyp_desc = Ptyp_object (ll, o) }])}]
when isJsDotTLongIdent lii.txt && List.length ll > 0 ->
Copy link
Member

Choose a reason for hiding this comment

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

Try ll <> []. O(1) check

Copy link
Member

Choose a reason for hiding this comment

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

Eh ops, just do ptyp_desc = Ptyp_object (_::_, o)

Copy link
Member

Choose a reason for hiding this comment

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

I'll correct that. Thanks!

@chenglou chenglou merged commit e5550dc into reasonml:master Jul 13, 2018
@anmonteiro anmonteiro deleted the anmonteiro/gh-2073 branch August 10, 2018 15:48
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.

Parens hugging for js.t obj types
4 participants