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

Eric Milles updated GROOVY-10755:
---------------------------------
    Language: groovy

> Ternary returning a list gets parsed improperly
> -----------------------------------------------
>
>                 Key: GROOVY-10755
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10755
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser, parser-antlr4
>    Affects Versions: 4.0.4
>            Reporter: OC
>            Priority: Minor
>
> Another problem with ternary operator, this time almost surely a clash with 
> the safe index operator:
> {code:java}
> 2034 ocs /tmp> >q.groovy 
> 1>2?[1]:0
> 2035 ocs /tmp> /usr/local/groovy-4.0.4/bin/groovy q   
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> /private/tmp/q.groovy: 1: Unexpected input: ':' @ line 1, column 8.
>    1>2?[1]:0
>           ^
> 1 error
> 2036 ocs /tmp> 
> {code}
> Most probably affects 4 from the beginning. Used to work properly in previous 
> versions (including Groovy 3 which supported the safe index operator all 
> right).
> The issue can be fixed easily e.g. inserting a space betwixt ? and [, thus 
> the minor priority. Nevertheless it is somewhat inconvenient since the 
> operation is pretty common and frequently occurs in the current codebase, 
> which worked under 3 all right. Also, it is sort of difficult to solve it 
> (semi-)automatically, for it is not entirely trivial to distinguish real safe 
> indices from ternaries automatically without a full-fledged parser :(



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to