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

Paul King edited comment on GROOVY-8941 at 1/14/19 5:22 AM:
------------------------------------------------------------

I changed the Summary since the behavior with 2.4/2.5 is not non-deterministic 
- it always behaves the same way. It is just unexpected in one case. For this 
code:
{code}
process test {
    // inner command chain
}
{code}
It throws a {{MissingPropertyExpression}} if the inner command chain is:
{code}
file('output.txt') into b, c
{code}
but throws a {{MissingMethodException}} in these cases:
{code}
file 'output.txt' into b, c
file 'output.txt' into(b, c)
file('output.txt').into b, c
file('output.txt') into(b, c)
file('output.txt').into(b, c)
file('output.txt') into b, c
{code}
It treats all cases the same in Groovy 3. In fact, we may close as fixed in 
Groovy 4, but it would be worth just checking the parsing rules to understand 
why it behaves this way first. I seem to recall that we made some improvements 
for consistency in Groovy 3 but can't remember the exact details.


was (Author: paulk):
I changed the Summary since the behavior with 2.4/2.5 is not non-deterministic 
- it always behaves the same way. It is just unexpected in one case. For this 
code:
{code}
process test {
    // inner command chain
}
{code}
It throws a {{MissingPropertyExpression}} if the inner command chain is:
{code}
file('output.txt') into b, c
{code}
but throws a {{MissingMethodException}} in these cases:
{code}
file 'output.txt' into b, c
file 'output.txt' into(b, c)
file('output.txt').into b, c
file('output.txt') into(b, c)
file('output.txt').into(b, c)
file('output.txt') into b, c
{code}
It treats all cases the same in Groovy 3.

> unexpected parsing of command chain with nested command chain
> -------------------------------------------------------------
>
>                 Key: GROOVY-8941
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8941
>             Project: Groovy
>          Issue Type: Bug
>          Components: Groovy Console
>    Affects Versions: 2.5.2
>         Environment: jdk: oracle jdk 1.8.0_191
> groovy: 2.5.2
> os: windows
>            Reporter: ShaoXian Song
>            Priority: Major
>              Labels: dsl
>
> I'm using groovyConsole to see the generated class code of the following two 
> Groovy scripts:
> {code:java}
> process test{
>     output:
>     file 'output.txt' into b, c
>     """
>     echo hello
>     """
> }
> {code}
> Here is its generated code snippet like below:
> {code:java}
> public java.lang.Object run() {
> this.process(this.test({ 
> this.file('output.txt').into(b, c)
> '\n echo hello\n '
> }))
> }
> {code}
> And here is the second script that differs from the previous one - this one 
> uses parentheses in file() method invocation:
> {code:java}
> process test{
>     output:
>     file('output.txt') into b, c
>     """
>     echo hello
>     """
> }
> {code}
> And this is generated code from the second script:
> {code:java}
> public java.lang.Object run() {
> process.test({ 
> this.file('output.txt').into(b, c)
> '\n echo hello\n '
> })
> }
> {code}
>  As you can see, {{process}} is no longer a function but a variable. It 
> confuses me because I would expect that in both cases {{process}} should be 
> seen as a function call. Is this an expected behavior? Do I miss something?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to