-
Notifications
You must be signed in to change notification settings - Fork 428
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
remove unnecessary parens around float & integer constants in constructor expr/fun app #1634
Conversation
/* Retain this */ | ||
X(2, 3) | ||
X | ||
(2, 3) /* Retain this */ |
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.
not sure why this happening
* pass through this case. In this context they don't need to be wrapped in extra parens | ||
* Some((-1)) should be printed as Some(-1). This is in contrast with | ||
* 1 + (-1) where we print the parens for readability. *) | ||
self#constant ~parens:(false || ensureExpr) c |
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.
Can remove false
|
||
Some(-0.1G, -0.1x, -0.1H); | ||
|
||
Some([@foo] (-1), [@foo] (-1), [@foo] (-1)); |
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.
It's possible to not print the parens in this case, should we remove them?
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.
I think so? The fewer the better =D
Did you see there was a high pri bug someone found with unary negation and named arguments? Does this make those matters worse? Worth adding a test case (even if it has to be disabled) |
Hmm I've seen it, this PR seems like a good opportunity to fix the high pri bug too. |
Should I wait til you add more tests? |
Yes, with a bit of a luck I can fix it too. |
720bdfe
to
090ebdb
Compare
@chenglou this is ready, added extra tests & removed the extra parens when printing with attributes |
let parens = if parens then (i.[0]='-') else false in | ||
paren parens (fun f -> pp f "%s") f i | ||
| Pconst_float (i, Some m) -> | ||
let parens = if parens then (i.[0]='-') else false in |
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 can be simplified to parens && i.[0]='-'
or maybe even inlined. Up to you
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.
done
Merging! Thanks. |
fixes #1630