Skip to content

[2.10.2] Parens inserted break cast expression in combination with increment #987

Closed

Description

@jkillian

Prettier-Java 2.10.12

Input:

b[off] = (byte) produced++;

Output:

b[off] = ((byte) produced)++;

Expected behavior:
Parens that are inserted (if any) shouldn't affect the meaning. In this case, the input is equivalent to:

(byte) (produced++)

so prettier is actually breaking the code by adding the parens the way that it does.

I didn't bisect to see which release introduced the issue, but we hit it when upgrading from 2.7.7.

Activity

  1. changed the title [-]Parens inserted break cast expression in combination with increment[/-] [+][2.10.2] Parens inserted break cast expression in combination with increment[/+] on Jul 17, 2026
  2. jtkiesel commented on Jul 18, 2026

    @jtkiesel
    Contributor

    Thank you for reporting this issue!

    I have determined that this is caused by an issue with the structure of the tree-sitter-java-orchard grammar that is now used by prettier-plugin-java. I've created the following PR to fix the issue: https://codeberg.org/grammar-orchard/tree-sitter-java-orchard/pulls/23

    I'll give the other maintainers a day or so to review it if they have time to do so, then get it merged and released. Then I'll get a new release of prettier-plugin-java created that uses it.

    Thank you for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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