Skip to content

Groovy parser fails on assert and colon #6374

@greg-at-moderne

Description

@greg-at-moderne

What version of OpenRewrite are you using?

Current main = 52f563b

What is the smallest, simplest way to reproduce the problem?

    @Test
    void assertColon() {
        rewriteRun(
          groovy(
            """
            import java.util.Collection
            
            assert args : "Expecting the OpenWhisk home directory to passed"
            """
          )
        );
    }

when added to one of the Groovy tests fails with:

org.opentest4j.AssertionFailedError: [When parsing and printing the source code back to text without modifications, the printed source didn't match the original source code. This means there is a bug in the parser implementation itself. Please open an issue to report this, providing a sample of the code that generated this error. "file.groovy":
-assert args : "Expecting the OpenWhisk home directory to passed"
+assert assertargs : "Expecting the OpenWhisk home directory to passed"

OSS repro

https://github.com/apache/openwhisk/blob/b8c934407ce96ba78f83099d8d4f9c3bd736e33b/tools/dev/src/main/groovy/couchdbViews.groovy#L20C1-L20C65

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggroovyparsertest providedAlready replicated with a unit test, using JUnit pioneer's ExpectedToFail

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions