Skip to content

[2.10.0] Wrongly removes parentheses #948

Description

@boris-petrov

Prettier-Java 2.10.0

--print-width 80

Input:

return a != null && (b == c);
(minimumRelevanceScore * 2) - 1;

Output:

return a != null && b == c;
minimumRelevanceScore * 2 - 1;

Expected behavior:
Unchanged.

The second line is not technically incorrect but I personally don't like parentheses removed in such expressions. There is a long-standing issue in Prettier for JS for the same thing. The first one is wrong because it changes the meaning of the program.

P.S. I now see that Prettier for JS does the same thing. Horrible. And maybe it's because of the same issue. I would like Prettier for Java to be better than that! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions