You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (Jira)" <ji...@apache.org> on 2019/11/19 00:15:00 UTC

[jira] [Commented] (GROOVY-9304) [Parrot] bitwise or followed by closure on next line parsed as command expression

    [ https://issues.apache.org/jira/browse/GROOVY-9304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16977013#comment-16977013 ] 

Daniel Sun commented on GROOVY-9304:
------------------------------------

The old parser behaves a bit strangely, e.g.

{code:java}
def x(c) { c() }

x 
{
    println 123
}
{code}

The followed closure will be parsed as a parameter.
But in this issue, the closure is parsed into another seperate expression...
Here is an workaround:
{code:java}
a | b;     // add the semi colon here
{it -> true} ()
{code}



> [Parrot] bitwise or followed by closure on next line parsed as command expression
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-9304
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9304
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr4
>    Affects Versions: 3.x
>            Reporter: Alexey Afanasiev
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-rc-2
>
>
> This code:
> {code:java}
> a | b
> {it -> true} (){code}
> will be parsed at 2.5.5 as two independent expressions:
> {code:java}
> a | b 
> { java.lang.Object it -> true}.call()
> {code}
> and will be parsed at 3.0.0-rc-1 as single expression:
> {code:java}
> a | this.b({ java.lang.Object it -> true }).call()
> {code}
> I believe this expression should be parsed same way in both versions.
> Spock depends on structure of ast for these kind of expressions. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)