Skip to content

Assignments inside condition do not work with Parenthesis removal #3913

@koppor

Description

@koppor

I updated openrewrite:

-    id 'org.openrewrite.rewrite' version '6.6.3'
+    id 'org.openrewrite.rewrite' version '6.6.6'

-    rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.5.4"))
+    rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.6.1"))

Some more parentheses are removed here.

I have some WTF parts in the code with assignments inside (!) if conditions. When removing parentheses here, it leads to a compiler error

-        if ((str == null) || ((end = str.length()) == 0) || ((((ch = str.charAt(0)) < '0') || (ch > '9')) && (!(sign = ch == '-') || (++idx == end) || ((ch = str.charAt(idx)) < '0') || (ch > '9')))) {
+        if ((str == null) || ((end = str.length()) == 0) || ((((ch = str.charAt(0)) < '0') || (ch > '9')) && (!sign = ch == '-' || (++idx == end) || ((ch = str.charAt(idx)) < '0') || (ch > '9')))) {
C:\git-repositories\jabref-all\jabref\src\main\java\org\jabref\model\strings\StringUtil.java:486: error: unexpected type
        if ((str == null) || ((end = str.length()) == 0) || ((((ch = str.charAt(0)) < '0') || (ch > '9')) && (!sign = ch == '-' || (++idx == end) || ((ch = str.charAt(idx)) < '0') || (ch > '9')))) {
                                                                                                              ^
  required: variable
  found:    value

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions