[ 
https://issues.apache.org/jira/browse/GROOVY-6549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-6549.
--------------------------------
    Resolution: Fixed

> Operand evaluation order for the '=' operator is incorrect
> ----------------------------------------------------------
>
>                 Key: GROOVY-6549
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6549
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.2.1
>            Reporter: Ed Clark
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 7.0.0-alpha-1
>
>
> When I run the following in the groovyConsole:
> {code:Java}
> e = []
> f = { -> println 'LHS'; return 1 }
> g = { -> println 'RHS'; return 4 }
> e[ f()] = g()
> println 'e = ' + e
> // test if an invalid LHS errors out before the RHS
> f = { -> println 'LHS'; return null }
> e[ f()] = g()
> println 'e = ' + e
> {code}
> I get:
> {code}
> RHS
> LHS
> e = [null, 4]
> RHS
> LHS
> Exception thrown
> {code}
> The right hand side operand for '=' is being evaluated before the left hand 
> side.
> This does not match the expected order (nor that of Java).  It can interfere 
> with DSL processing.
> Note, the compiler does evaluate the operands for setAt and putAt in the 
> correct order.  It seems that the '=' operator is handled separately by the 
> compiler.
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to