-
Notifications
You must be signed in to change notification settings - Fork 429
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
Only wrap Pexp_function
in parens when necessary
#2033
Conversation
@@ -5603,9 +5606,6 @@ let printer = object(self:'self) | |||
match x'.pexp_desc with | |||
| Pexp_let _ -> | |||
Some (makeLetSequence (self#letList x)) | |||
| Pexp_function l when (pipe || semi) -> |
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.
this case was useless. Pexp_function
would be caught by expression_immediate_extension_sugar
Pexp_function
in parens when unnecessary
Pexp_function
in parens when unnecessaryPexp_function
in parens when necessary
I've found it very difficult to prove that it is safe to omit parenthesis around functions when they are embedded in infix expressions, and when they return infix function applications. To merge this I think we want to have a lot more test cases where the function returns something that applies infix |
@jordwalke thanks for the feedback. In coming up with test cases, the following example does indeed print incorrectly with the current changes: (fun
| None => x >>= y
| Some(x) => x >>= y)
>>= bar ;
/* becomes this, which doesn't pass idempotency */
fun
| None => x >>= y
| Some(x) => x >>= y
>>= bar; I wonder if we can play with the precedence rues to make it work? I'm trying that right now. |
@jordwalke I think I added your suggested test cases, let me know if you'd like to see more (and which). The latest changes introduce a custom |
79f6fe2
to
9f37e4d
Compare
fixes reasonml#2032 before: ```reason let predicate = predicate === Functions.alwaysTrue1 ? defaultPredicate : ( fun | None => false | Some(exn) => predicate(exn) ); ``` after: ```reason let predicate = predicate === Functions.alwaysTrue1 ? defaultPredicate : fun | None => false | Some(exn) => predicate(exn); ```
@chenglou I don't immediately see anything wrong with this PR, let's merge? |
Thanks. Though I’ll hold off meeting for a day or two. New release now |
Thanks! |
fixes #2032
before:
after: